0
|
1 /*
|
|
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 *
|
|
5 * This code is free software; you can redistribute it and/or modify it
|
|
6 * under the terms of the GNU General Public License version 2 only, as
|
|
7 * published by the Free Software Foundation.
|
|
8 *
|
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
|
13 * accompanied this code).
|
|
14 *
|
|
15 * You should have received a copy of the GNU General Public License version
|
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 // Portions of code courtesy of Clifford Click
|
|
26
|
|
27 // Optimization - Graph Style
|
|
28
|
|
29
|
|
30 // This class defines a Type lattice. The lattice is used in the constant
|
|
31 // propagation algorithms, and for some type-checking of the iloc code.
|
|
32 // Basic types include RSD's (lower bound, upper bound, stride for integers),
|
|
33 // float & double precision constants, sets of data-labels and code-labels.
|
|
34 // The complete lattice is described below. Subtypes have no relationship to
|
|
35 // up or down in the lattice; that is entirely determined by the behavior of
|
|
36 // the MEET/JOIN functions.
|
|
37
|
|
38 class Dict;
|
|
39 class Type;
|
|
40 class TypeD;
|
|
41 class TypeF;
|
|
42 class TypeInt;
|
|
43 class TypeLong;
|
|
44 class TypeAry;
|
|
45 class TypeTuple;
|
|
46 class TypePtr;
|
|
47 class TypeRawPtr;
|
|
48 class TypeOopPtr;
|
|
49 class TypeInstPtr;
|
|
50 class TypeAryPtr;
|
|
51 class TypeKlassPtr;
|
|
52
|
|
53 //------------------------------Type-------------------------------------------
|
|
54 // Basic Type object, represents a set of primitive Values.
|
|
55 // Types are hash-cons'd into a private class dictionary, so only one of each
|
|
56 // different kind of Type exists. Types are never modified after creation, so
|
|
57 // all their interesting fields are constant.
|
|
58 class Type {
|
|
59 public:
|
|
60 enum TYPES {
|
|
61 Bad=0, // Type check
|
|
62 Control, // Control of code (not in lattice)
|
|
63 Top, // Top of the lattice
|
|
64 Int, // Integer range (lo-hi)
|
|
65 Long, // Long integer range (lo-hi)
|
|
66 Half, // Placeholder half of doubleword
|
|
67
|
|
68 Tuple, // Method signature or object layout
|
|
69 Array, // Array types
|
|
70
|
|
71 AnyPtr, // Any old raw, klass, inst, or array pointer
|
|
72 RawPtr, // Raw (non-oop) pointers
|
|
73 OopPtr, // Any and all Java heap entities
|
|
74 InstPtr, // Instance pointers (non-array objects)
|
|
75 AryPtr, // Array pointers
|
|
76 KlassPtr, // Klass pointers
|
|
77 // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
|
|
78
|
|
79 Function, // Function signature
|
|
80 Abio, // Abstract I/O
|
|
81 Return_Address, // Subroutine return address
|
|
82 Memory, // Abstract store
|
|
83 FloatTop, // No float value
|
|
84 FloatCon, // Floating point constant
|
|
85 FloatBot, // Any float value
|
|
86 DoubleTop, // No double value
|
|
87 DoubleCon, // Double precision constant
|
|
88 DoubleBot, // Any double value
|
|
89 Bottom, // Bottom of lattice
|
|
90 lastype // Bogus ending type (not in lattice)
|
|
91 };
|
|
92
|
|
93 // Signal values for offsets from a base pointer
|
|
94 enum OFFSET_SIGNALS {
|
|
95 OffsetTop = -2000000000, // undefined offset
|
|
96 OffsetBot = -2000000001 // any possible offset
|
|
97 };
|
|
98
|
|
99 // Min and max WIDEN values.
|
|
100 enum WIDEN {
|
|
101 WidenMin = 0,
|
|
102 WidenMax = 3
|
|
103 };
|
|
104
|
|
105 private:
|
|
106 // Dictionary of types shared among compilations.
|
|
107 static Dict* _shared_type_dict;
|
|
108
|
|
109 static int uhash( const Type *const t );
|
|
110 // Structural equality check. Assumes that cmp() has already compared
|
|
111 // the _base types and thus knows it can cast 't' appropriately.
|
|
112 virtual bool eq( const Type *t ) const;
|
|
113
|
|
114 // Top-level hash-table of types
|
|
115 static Dict *type_dict() {
|
|
116 return Compile::current()->type_dict();
|
|
117 }
|
|
118
|
|
119 // DUAL operation: reflect around lattice centerline. Used instead of
|
|
120 // join to ensure my lattice is symmetric up and down. Dual is computed
|
|
121 // lazily, on demand, and cached in _dual.
|
|
122 const Type *_dual; // Cached dual value
|
|
123 // Table for efficient dualing of base types
|
|
124 static const TYPES dual_type[lastype];
|
|
125
|
|
126 protected:
|
|
127 // Each class of type is also identified by its base.
|
|
128 const TYPES _base; // Enum of Types type
|
|
129
|
|
130 Type( TYPES t ) : _dual(NULL), _base(t) {} // Simple types
|
|
131 // ~Type(); // Use fast deallocation
|
|
132 const Type *hashcons(); // Hash-cons the type
|
|
133
|
|
134 public:
|
|
135
|
|
136 inline void* operator new( size_t x ) {
|
|
137 Compile* compile = Compile::current();
|
|
138 compile->set_type_last_size(x);
|
|
139 void *temp = compile->type_arena()->Amalloc_D(x);
|
|
140 compile->set_type_hwm(temp);
|
|
141 return temp;
|
|
142 }
|
|
143 inline void operator delete( void* ptr ) {
|
|
144 Compile* compile = Compile::current();
|
|
145 compile->type_arena()->Afree(ptr,compile->type_last_size());
|
|
146 }
|
|
147
|
|
148 // Initialize the type system for a particular compilation.
|
|
149 static void Initialize(Compile* compile);
|
|
150
|
|
151 // Initialize the types shared by all compilations.
|
|
152 static void Initialize_shared(Compile* compile);
|
|
153
|
|
154 TYPES base() const {
|
|
155 assert(_base > Bad && _base < lastype, "sanity");
|
|
156 return _base;
|
|
157 }
|
|
158
|
|
159 // Create a new hash-consd type
|
|
160 static const Type *make(enum TYPES);
|
|
161 // Test for equivalence of types
|
|
162 static int cmp( const Type *const t1, const Type *const t2 );
|
|
163 // Test for higher or equal in lattice
|
|
164 int higher_equal( const Type *t ) const { return !cmp(meet(t),t); }
|
|
165
|
|
166 // MEET operation; lower in lattice.
|
|
167 const Type *meet( const Type *t ) const;
|
|
168 // WIDEN: 'widens' for Ints and other range types
|
|
169 virtual const Type *widen( const Type *old ) const { return this; }
|
|
170 // NARROW: complement for widen, used by pessimistic phases
|
|
171 virtual const Type *narrow( const Type *old ) const { return this; }
|
|
172
|
|
173 // DUAL operation: reflect around lattice centerline. Used instead of
|
|
174 // join to ensure my lattice is symmetric up and down.
|
|
175 const Type *dual() const { return _dual; }
|
|
176
|
|
177 // Compute meet dependent on base type
|
|
178 virtual const Type *xmeet( const Type *t ) const;
|
|
179 virtual const Type *xdual() const; // Compute dual right now.
|
|
180
|
|
181 // JOIN operation; higher in lattice. Done by finding the dual of the
|
|
182 // meet of the dual of the 2 inputs.
|
|
183 const Type *join( const Type *t ) const {
|
|
184 return dual()->meet(t->dual())->dual(); }
|
|
185
|
|
186 // Modified version of JOIN adapted to the needs Node::Value.
|
|
187 // Normalizes all empty values to TOP. Does not kill _widen bits.
|
|
188 // Currently, it also works around limitations involving interface types.
|
|
189 virtual const Type *filter( const Type *kills ) const;
|
|
190
|
|
191 // Convenience access
|
|
192 float getf() const;
|
|
193 double getd() const;
|
|
194
|
|
195 const TypeInt *is_int() const;
|
|
196 const TypeInt *isa_int() const; // Returns NULL if not an Int
|
|
197 const TypeLong *is_long() const;
|
|
198 const TypeLong *isa_long() const; // Returns NULL if not a Long
|
|
199 const TypeD *is_double_constant() const; // Asserts it is a DoubleCon
|
|
200 const TypeD *isa_double_constant() const; // Returns NULL if not a DoubleCon
|
|
201 const TypeF *is_float_constant() const; // Asserts it is a FloatCon
|
|
202 const TypeF *isa_float_constant() const; // Returns NULL if not a FloatCon
|
|
203 const TypeTuple *is_tuple() const; // Collection of fields, NOT a pointer
|
|
204 const TypeAry *is_ary() const; // Array, NOT array pointer
|
|
205 const TypePtr *is_ptr() const; // Asserts it is a ptr type
|
|
206 const TypePtr *isa_ptr() const; // Returns NULL if not ptr type
|
|
207 const TypeRawPtr *is_rawptr() const; // NOT Java oop
|
|
208 const TypeOopPtr *isa_oopptr() const; // Returns NULL if not ptr type
|
|
209 const TypeKlassPtr *isa_klassptr() const; // Returns NULL if not KlassPtr
|
|
210 const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr
|
|
211 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer
|
|
212 const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr
|
|
213 const TypeInstPtr *is_instptr() const; // Instance
|
|
214 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr
|
|
215 const TypeAryPtr *is_aryptr() const; // Array oop
|
|
216 virtual bool is_finite() const; // Has a finite value
|
|
217 virtual bool is_nan() const; // Is not a number (NaN)
|
|
218
|
|
219 // Special test for register pressure heuristic
|
|
220 bool is_floatingpoint() const; // True if Float or Double base type
|
|
221
|
|
222 // Do you have memory, directly or through a tuple?
|
|
223 bool has_memory( ) const;
|
|
224
|
|
225 // Are you a pointer type or not?
|
|
226 bool isa_oop_ptr() const;
|
|
227
|
|
228 // TRUE if type is a singleton
|
|
229 virtual bool singleton(void) const;
|
|
230
|
|
231 // TRUE if type is above the lattice centerline, and is therefore vacuous
|
|
232 virtual bool empty(void) const;
|
|
233
|
|
234 // Return a hash for this type. The hash function is public so ConNode
|
|
235 // (constants) can hash on their constant, which is represented by a Type.
|
|
236 virtual int hash() const;
|
|
237
|
|
238 // Map ideal registers (machine types) to ideal types
|
|
239 static const Type *mreg2type[];
|
|
240
|
|
241 // Printing, statistics
|
|
242 static const char * const msg[lastype]; // Printable strings
|
|
243 #ifndef PRODUCT
|
|
244 void dump_on(outputStream *st) const;
|
|
245 void dump() const {
|
|
246 dump_on(tty);
|
|
247 }
|
|
248 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
|
249 static void dump_stats();
|
|
250 static void verify_lastype(); // Check that arrays match type enum
|
|
251 #endif
|
|
252 void typerr(const Type *t) const; // Mixing types error
|
|
253
|
|
254 // Create basic type
|
|
255 static const Type* get_const_basic_type(BasicType type) {
|
|
256 assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type");
|
|
257 return _const_basic_type[type];
|
|
258 }
|
|
259
|
|
260 // Mapping to the array element's basic type.
|
|
261 BasicType array_element_basic_type() const;
|
|
262
|
|
263 // Create standard type for a ciType:
|
|
264 static const Type* get_const_type(ciType* type);
|
|
265
|
|
266 // Create standard zero value:
|
|
267 static const Type* get_zero_type(BasicType type) {
|
|
268 assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
|
|
269 return _zero_type[type];
|
|
270 }
|
|
271
|
|
272 // Report if this is a zero value (not top).
|
|
273 bool is_zero_type() const {
|
|
274 BasicType type = basic_type();
|
|
275 if (type == T_VOID || type >= T_CONFLICT)
|
|
276 return false;
|
|
277 else
|
|
278 return (this == _zero_type[type]);
|
|
279 }
|
|
280
|
|
281 // Convenience common pre-built types.
|
|
282 static const Type *ABIO;
|
|
283 static const Type *BOTTOM;
|
|
284 static const Type *CONTROL;
|
|
285 static const Type *DOUBLE;
|
|
286 static const Type *FLOAT;
|
|
287 static const Type *HALF;
|
|
288 static const Type *MEMORY;
|
|
289 static const Type *MULTI;
|
|
290 static const Type *RETURN_ADDRESS;
|
|
291 static const Type *TOP;
|
|
292
|
|
293 // Mapping from compiler type to VM BasicType
|
|
294 BasicType basic_type() const { return _basic_type[_base]; }
|
|
295
|
|
296 // Mapping from CI type system to compiler type:
|
|
297 static const Type* get_typeflow_type(ciType* type);
|
|
298
|
|
299 private:
|
|
300 // support arrays
|
|
301 static const BasicType _basic_type[];
|
|
302 static const Type* _zero_type[T_CONFLICT+1];
|
|
303 static const Type* _const_basic_type[T_CONFLICT+1];
|
|
304 };
|
|
305
|
|
306 //------------------------------TypeF------------------------------------------
|
|
307 // Class of Float-Constant Types.
|
|
308 class TypeF : public Type {
|
|
309 TypeF( float f ) : Type(FloatCon), _f(f) {};
|
|
310 public:
|
|
311 virtual bool eq( const Type *t ) const;
|
|
312 virtual int hash() const; // Type specific hashing
|
|
313 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
314 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
315 public:
|
|
316 const float _f; // Float constant
|
|
317
|
|
318 static const TypeF *make(float f);
|
|
319
|
|
320 virtual bool is_finite() const; // Has a finite value
|
|
321 virtual bool is_nan() const; // Is not a number (NaN)
|
|
322
|
|
323 virtual const Type *xmeet( const Type *t ) const;
|
|
324 virtual const Type *xdual() const; // Compute dual right now.
|
|
325 // Convenience common pre-built types.
|
|
326 static const TypeF *ZERO; // positive zero only
|
|
327 static const TypeF *ONE;
|
|
328 #ifndef PRODUCT
|
|
329 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
|
330 #endif
|
|
331 };
|
|
332
|
|
333 //------------------------------TypeD------------------------------------------
|
|
334 // Class of Double-Constant Types.
|
|
335 class TypeD : public Type {
|
|
336 TypeD( double d ) : Type(DoubleCon), _d(d) {};
|
|
337 public:
|
|
338 virtual bool eq( const Type *t ) const;
|
|
339 virtual int hash() const; // Type specific hashing
|
|
340 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
341 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
342 public:
|
|
343 const double _d; // Double constant
|
|
344
|
|
345 static const TypeD *make(double d);
|
|
346
|
|
347 virtual bool is_finite() const; // Has a finite value
|
|
348 virtual bool is_nan() const; // Is not a number (NaN)
|
|
349
|
|
350 virtual const Type *xmeet( const Type *t ) const;
|
|
351 virtual const Type *xdual() const; // Compute dual right now.
|
|
352 // Convenience common pre-built types.
|
|
353 static const TypeD *ZERO; // positive zero only
|
|
354 static const TypeD *ONE;
|
|
355 #ifndef PRODUCT
|
|
356 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
|
357 #endif
|
|
358 };
|
|
359
|
|
360 //------------------------------TypeInt----------------------------------------
|
|
361 // Class of integer ranges, the set of integers between a lower bound and an
|
|
362 // upper bound, inclusive.
|
|
363 class TypeInt : public Type {
|
|
364 TypeInt( jint lo, jint hi, int w );
|
|
365 public:
|
|
366 virtual bool eq( const Type *t ) const;
|
|
367 virtual int hash() const; // Type specific hashing
|
|
368 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
369 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
370 public:
|
|
371 const jint _lo, _hi; // Lower bound, upper bound
|
|
372 const short _widen; // Limit on times we widen this sucker
|
|
373
|
|
374 static const TypeInt *make(jint lo);
|
|
375 // must always specify w
|
|
376 static const TypeInt *make(jint lo, jint hi, int w);
|
|
377
|
|
378 // Check for single integer
|
|
379 int is_con() const { return _lo==_hi; }
|
|
380 bool is_con(int i) const { return is_con() && _lo == i; }
|
|
381 jint get_con() const { assert( is_con(), "" ); return _lo; }
|
|
382
|
|
383 virtual bool is_finite() const; // Has a finite value
|
|
384
|
|
385 virtual const Type *xmeet( const Type *t ) const;
|
|
386 virtual const Type *xdual() const; // Compute dual right now.
|
|
387 virtual const Type *widen( const Type *t ) const;
|
|
388 virtual const Type *narrow( const Type *t ) const;
|
|
389 // Do not kill _widen bits.
|
|
390 virtual const Type *filter( const Type *kills ) const;
|
|
391 // Convenience common pre-built types.
|
|
392 static const TypeInt *MINUS_1;
|
|
393 static const TypeInt *ZERO;
|
|
394 static const TypeInt *ONE;
|
|
395 static const TypeInt *BOOL;
|
|
396 static const TypeInt *CC;
|
|
397 static const TypeInt *CC_LT; // [-1] == MINUS_1
|
|
398 static const TypeInt *CC_GT; // [1] == ONE
|
|
399 static const TypeInt *CC_EQ; // [0] == ZERO
|
|
400 static const TypeInt *CC_LE; // [-1,0]
|
|
401 static const TypeInt *CC_GE; // [0,1] == BOOL (!)
|
|
402 static const TypeInt *BYTE;
|
|
403 static const TypeInt *CHAR;
|
|
404 static const TypeInt *SHORT;
|
|
405 static const TypeInt *POS;
|
|
406 static const TypeInt *POS1;
|
|
407 static const TypeInt *INT;
|
|
408 static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
|
|
409 #ifndef PRODUCT
|
|
410 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
|
411 #endif
|
|
412 };
|
|
413
|
|
414
|
|
415 //------------------------------TypeLong---------------------------------------
|
|
416 // Class of long integer ranges, the set of integers between a lower bound and
|
|
417 // an upper bound, inclusive.
|
|
418 class TypeLong : public Type {
|
|
419 TypeLong( jlong lo, jlong hi, int w );
|
|
420 public:
|
|
421 virtual bool eq( const Type *t ) const;
|
|
422 virtual int hash() const; // Type specific hashing
|
|
423 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
424 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
425 public:
|
|
426 const jlong _lo, _hi; // Lower bound, upper bound
|
|
427 const short _widen; // Limit on times we widen this sucker
|
|
428
|
|
429 static const TypeLong *make(jlong lo);
|
|
430 // must always specify w
|
|
431 static const TypeLong *make(jlong lo, jlong hi, int w);
|
|
432
|
|
433 // Check for single integer
|
|
434 int is_con() const { return _lo==_hi; }
|
|
435 jlong get_con() const { assert( is_con(), "" ); return _lo; }
|
|
436
|
|
437 virtual bool is_finite() const; // Has a finite value
|
|
438
|
|
439 virtual const Type *xmeet( const Type *t ) const;
|
|
440 virtual const Type *xdual() const; // Compute dual right now.
|
|
441 virtual const Type *widen( const Type *t ) const;
|
|
442 virtual const Type *narrow( const Type *t ) const;
|
|
443 // Do not kill _widen bits.
|
|
444 virtual const Type *filter( const Type *kills ) const;
|
|
445 // Convenience common pre-built types.
|
|
446 static const TypeLong *MINUS_1;
|
|
447 static const TypeLong *ZERO;
|
|
448 static const TypeLong *ONE;
|
|
449 static const TypeLong *POS;
|
|
450 static const TypeLong *LONG;
|
|
451 static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint]
|
|
452 static const TypeLong *UINT; // 32-bit unsigned [0..max_juint]
|
|
453 #ifndef PRODUCT
|
|
454 virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping
|
|
455 #endif
|
|
456 };
|
|
457
|
|
458 //------------------------------TypeTuple--------------------------------------
|
|
459 // Class of Tuple Types, essentially type collections for function signatures
|
|
460 // and class layouts. It happens to also be a fast cache for the HotSpot
|
|
461 // signature types.
|
|
462 class TypeTuple : public Type {
|
|
463 TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
|
|
464 public:
|
|
465 virtual bool eq( const Type *t ) const;
|
|
466 virtual int hash() const; // Type specific hashing
|
|
467 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
468 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
469
|
|
470 public:
|
|
471 const uint _cnt; // Count of fields
|
|
472 const Type ** const _fields; // Array of field types
|
|
473
|
|
474 // Accessors:
|
|
475 uint cnt() const { return _cnt; }
|
|
476 const Type* field_at(uint i) const {
|
|
477 assert(i < _cnt, "oob");
|
|
478 return _fields[i];
|
|
479 }
|
|
480 void set_field_at(uint i, const Type* t) {
|
|
481 assert(i < _cnt, "oob");
|
|
482 _fields[i] = t;
|
|
483 }
|
|
484
|
|
485 static const TypeTuple *make( uint cnt, const Type **fields );
|
|
486 static const TypeTuple *make_range(ciSignature *sig);
|
|
487 static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
|
|
488
|
|
489 // Subroutine call type with space allocated for argument types
|
|
490 static const Type **fields( uint arg_cnt );
|
|
491
|
|
492 virtual const Type *xmeet( const Type *t ) const;
|
|
493 virtual const Type *xdual() const; // Compute dual right now.
|
|
494 // Convenience common pre-built types.
|
|
495 static const TypeTuple *IFBOTH;
|
|
496 static const TypeTuple *IFFALSE;
|
|
497 static const TypeTuple *IFTRUE;
|
|
498 static const TypeTuple *IFNEITHER;
|
|
499 static const TypeTuple *LOOPBODY;
|
|
500 static const TypeTuple *MEMBAR;
|
|
501 static const TypeTuple *STORECONDITIONAL;
|
|
502 static const TypeTuple *START_I2C;
|
|
503 static const TypeTuple *INT_PAIR;
|
|
504 static const TypeTuple *LONG_PAIR;
|
|
505 #ifndef PRODUCT
|
|
506 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
|
|
507 #endif
|
|
508 };
|
|
509
|
|
510 //------------------------------TypeAry----------------------------------------
|
|
511 // Class of Array Types
|
|
512 class TypeAry : public Type {
|
|
513 TypeAry( const Type *elem, const TypeInt *size) : Type(Array),
|
|
514 _elem(elem), _size(size) {}
|
|
515 public:
|
|
516 virtual bool eq( const Type *t ) const;
|
|
517 virtual int hash() const; // Type specific hashing
|
|
518 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
519 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
520
|
|
521 private:
|
|
522 const Type *_elem; // Element type of array
|
|
523 const TypeInt *_size; // Elements in array
|
|
524 friend class TypeAryPtr;
|
|
525
|
|
526 public:
|
|
527 static const TypeAry *make( const Type *elem, const TypeInt *size);
|
|
528
|
|
529 virtual const Type *xmeet( const Type *t ) const;
|
|
530 virtual const Type *xdual() const; // Compute dual right now.
|
|
531 bool ary_must_be_exact() const; // true if arrays of such are never generic
|
|
532 #ifndef PRODUCT
|
|
533 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
|
|
534 #endif
|
|
535 };
|
|
536
|
|
537 //------------------------------TypePtr----------------------------------------
|
|
538 // Class of machine Pointer Types: raw data, instances or arrays.
|
|
539 // If the _base enum is AnyPtr, then this refers to all of the above.
|
|
540 // Otherwise the _base will indicate which subset of pointers is affected,
|
|
541 // and the class will be inherited from.
|
|
542 class TypePtr : public Type {
|
|
543 public:
|
|
544 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
|
|
545 protected:
|
|
546 TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
|
|
547 virtual bool eq( const Type *t ) const;
|
|
548 virtual int hash() const; // Type specific hashing
|
|
549 static const PTR ptr_meet[lastPTR][lastPTR];
|
|
550 static const PTR ptr_dual[lastPTR];
|
|
551 static const char * const ptr_msg[lastPTR];
|
|
552
|
|
553 public:
|
|
554 const int _offset; // Offset into oop, with TOP & BOT
|
|
555 const PTR _ptr; // Pointer equivalence class
|
|
556
|
|
557 const int offset() const { return _offset; }
|
|
558 const PTR ptr() const { return _ptr; }
|
|
559
|
|
560 static const TypePtr *make( TYPES t, PTR ptr, int offset );
|
|
561
|
|
562 // Return a 'ptr' version of this type
|
|
563 virtual const Type *cast_to_ptr_type(PTR ptr) const;
|
|
564
|
|
565 virtual intptr_t get_con() const;
|
|
566
|
|
567 virtual const TypePtr *add_offset( int offset ) const;
|
|
568
|
|
569 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
570 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
571 virtual const Type *xmeet( const Type *t ) const;
|
|
572 int meet_offset( int offset ) const;
|
|
573 int dual_offset( ) const;
|
|
574 virtual const Type *xdual() const; // Compute dual right now.
|
|
575
|
|
576 // meet, dual and join over pointer equivalence sets
|
|
577 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
|
|
578 PTR dual_ptr() const { return ptr_dual[ptr()]; }
|
|
579
|
|
580 // This is textually confusing unless one recalls that
|
|
581 // join(t) == dual()->meet(t->dual())->dual().
|
|
582 PTR join_ptr( const PTR in_ptr ) const {
|
|
583 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
|
|
584 }
|
|
585
|
|
586 // Tests for relation to centerline of type lattice:
|
|
587 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
|
|
588 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
|
|
589 // Convenience common pre-built types.
|
|
590 static const TypePtr *NULL_PTR;
|
|
591 static const TypePtr *NOTNULL;
|
|
592 static const TypePtr *BOTTOM;
|
|
593 #ifndef PRODUCT
|
|
594 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
|
595 #endif
|
|
596 };
|
|
597
|
|
598 //------------------------------TypeRawPtr-------------------------------------
|
|
599 // Class of raw pointers, pointers to things other than Oops. Examples
|
|
600 // include the stack pointer, top of heap, card-marking area, handles, etc.
|
|
601 class TypeRawPtr : public TypePtr {
|
|
602 protected:
|
|
603 TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
|
|
604 public:
|
|
605 virtual bool eq( const Type *t ) const;
|
|
606 virtual int hash() const; // Type specific hashing
|
|
607
|
|
608 const address _bits; // Constant value, if applicable
|
|
609
|
|
610 static const TypeRawPtr *make( PTR ptr );
|
|
611 static const TypeRawPtr *make( address bits );
|
|
612
|
|
613 // Return a 'ptr' version of this type
|
|
614 virtual const Type *cast_to_ptr_type(PTR ptr) const;
|
|
615
|
|
616 virtual intptr_t get_con() const;
|
|
617
|
|
618 virtual const TypePtr *add_offset( int offset ) const;
|
|
619
|
|
620 virtual const Type *xmeet( const Type *t ) const;
|
|
621 virtual const Type *xdual() const; // Compute dual right now.
|
|
622 // Convenience common pre-built types.
|
|
623 static const TypeRawPtr *BOTTOM;
|
|
624 static const TypeRawPtr *NOTNULL;
|
|
625 #ifndef PRODUCT
|
|
626 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
|
627 #endif
|
|
628 };
|
|
629
|
|
630 //------------------------------TypeOopPtr-------------------------------------
|
|
631 // Some kind of oop (Java pointer), either klass or instance or array.
|
|
632 class TypeOopPtr : public TypePtr {
|
|
633 protected:
|
|
634 TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ) : TypePtr(t, ptr, offset), _const_oop(o), _klass(k), _klass_is_exact(xk), _instance_id(instance_id) { }
|
|
635 public:
|
|
636 virtual bool eq( const Type *t ) const;
|
|
637 virtual int hash() const; // Type specific hashing
|
|
638 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
639 enum {
|
|
640 UNKNOWN_INSTANCE = 0
|
|
641 };
|
|
642 protected:
|
|
643
|
|
644 int xadd_offset( int offset ) const;
|
|
645 // Oop is NULL, unless this is a constant oop.
|
|
646 ciObject* _const_oop; // Constant oop
|
|
647 // If _klass is NULL, then so is _sig. This is an unloaded klass.
|
|
648 ciKlass* _klass; // Klass object
|
|
649 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
|
|
650 bool _klass_is_exact;
|
|
651
|
|
652 int _instance_id; // if not UNKNOWN_INSTANCE, indicates that this is a particular instance
|
|
653 // of this type which is distinct. This is the the node index of the
|
|
654 // node creating this instance
|
|
655
|
|
656 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
|
|
657
|
|
658 int dual_instance() const { return -_instance_id; }
|
|
659 int meet_instance(int uid) const;
|
|
660
|
|
661 public:
|
|
662 // Creates a type given a klass. Correctly handles multi-dimensional arrays
|
|
663 // Respects UseUniqueSubclasses.
|
|
664 // If the klass is final, the resulting type will be exact.
|
|
665 static const TypeOopPtr* make_from_klass(ciKlass* klass) {
|
|
666 return make_from_klass_common(klass, true, false);
|
|
667 }
|
|
668 // Same as before, but will produce an exact type, even if
|
|
669 // the klass is not final, as long as it has exactly one implementation.
|
|
670 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
|
|
671 return make_from_klass_common(klass, true, true);
|
|
672 }
|
|
673 // Same as before, but does not respects UseUniqueSubclasses.
|
|
674 // Use this only for creating array element types.
|
|
675 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
|
|
676 return make_from_klass_common(klass, false, false);
|
|
677 }
|
|
678 // Creates a singleton type given an object.
|
|
679 static const TypeOopPtr* make_from_constant(ciObject* o);
|
|
680
|
|
681 // Make a generic (unclassed) pointer to an oop.
|
|
682 static const TypeOopPtr* make(PTR ptr, int offset);
|
|
683
|
|
684 ciObject* const_oop() const { return _const_oop; }
|
|
685 virtual ciKlass* klass() const { return _klass; }
|
|
686 bool klass_is_exact() const { return _klass_is_exact; }
|
|
687 bool is_instance() const { return _instance_id != UNKNOWN_INSTANCE; }
|
|
688 uint instance_id() const { return _instance_id; }
|
|
689
|
|
690 virtual intptr_t get_con() const;
|
|
691
|
|
692 virtual const Type *cast_to_ptr_type(PTR ptr) const;
|
|
693
|
|
694 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
|
|
695
|
|
696 virtual const TypeOopPtr *cast_to_instance(int instance_id) const;
|
|
697
|
|
698 // corresponding pointer to klass, for a given instance
|
|
699 const TypeKlassPtr* as_klass_type() const;
|
|
700
|
|
701 virtual const TypePtr *add_offset( int offset ) const;
|
|
702
|
|
703 virtual const Type *xmeet( const Type *t ) const;
|
|
704 virtual const Type *xdual() const; // Compute dual right now.
|
|
705
|
|
706 // Do not allow interface-vs.-noninterface joins to collapse to top.
|
|
707 virtual const Type *filter( const Type *kills ) const;
|
|
708
|
|
709 // Convenience common pre-built type.
|
|
710 static const TypeOopPtr *BOTTOM;
|
|
711 #ifndef PRODUCT
|
|
712 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
|
|
713 #endif
|
|
714 };
|
|
715
|
|
716 //------------------------------TypeInstPtr------------------------------------
|
|
717 // Class of Java object pointers, pointing either to non-array Java instances
|
|
718 // or to a klassOop (including array klasses).
|
|
719 class TypeInstPtr : public TypeOopPtr {
|
|
720 TypeInstPtr( PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id );
|
|
721 virtual bool eq( const Type *t ) const;
|
|
722 virtual int hash() const; // Type specific hashing
|
|
723
|
|
724 ciSymbol* _name; // class name
|
|
725
|
|
726 public:
|
|
727 ciSymbol* name() const { return _name; }
|
|
728
|
|
729 bool is_loaded() const { return _klass->is_loaded(); }
|
|
730
|
|
731 // Make a pointer to a constant oop.
|
|
732 static const TypeInstPtr *make(ciObject* o) {
|
|
733 return make(TypePtr::Constant, o->klass(), true, o, 0);
|
|
734 }
|
|
735
|
|
736 // Make a pointer to a constant oop with offset.
|
|
737 static const TypeInstPtr *make(ciObject* o, int offset) {
|
|
738 return make(TypePtr::Constant, o->klass(), true, o, offset);
|
|
739 }
|
|
740
|
|
741 // Make a pointer to some value of type klass.
|
|
742 static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
|
|
743 return make(ptr, klass, false, NULL, 0);
|
|
744 }
|
|
745
|
|
746 // Make a pointer to some non-polymorphic value of exactly type klass.
|
|
747 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
|
|
748 return make(ptr, klass, true, NULL, 0);
|
|
749 }
|
|
750
|
|
751 // Make a pointer to some value of type klass with offset.
|
|
752 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
|
|
753 return make(ptr, klass, false, NULL, offset);
|
|
754 }
|
|
755
|
|
756 // Make a pointer to an oop.
|
|
757 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = 0 );
|
|
758
|
|
759 // If this is a java.lang.Class constant, return the type for it or NULL.
|
|
760 // Pass to Type::get_const_type to turn it to a type, which will usually
|
|
761 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
|
|
762 ciType* java_mirror_type() const;
|
|
763
|
|
764 virtual const Type *cast_to_ptr_type(PTR ptr) const;
|
|
765
|
|
766 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
|
|
767
|
|
768 virtual const TypeOopPtr *cast_to_instance(int instance_id) const;
|
|
769
|
|
770 virtual const TypePtr *add_offset( int offset ) const;
|
|
771
|
|
772 virtual const Type *xmeet( const Type *t ) const;
|
|
773 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
|
|
774 virtual const Type *xdual() const; // Compute dual right now.
|
|
775
|
|
776 // Convenience common pre-built types.
|
|
777 static const TypeInstPtr *NOTNULL;
|
|
778 static const TypeInstPtr *BOTTOM;
|
|
779 static const TypeInstPtr *MIRROR;
|
|
780 static const TypeInstPtr *MARK;
|
|
781 static const TypeInstPtr *KLASS;
|
|
782 #ifndef PRODUCT
|
|
783 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
|
|
784 #endif
|
|
785 };
|
|
786
|
|
787 //------------------------------TypeAryPtr-------------------------------------
|
|
788 // Class of Java array pointers
|
|
789 class TypeAryPtr : public TypeOopPtr {
|
|
790 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id), _ary(ary) {};
|
|
791 virtual bool eq( const Type *t ) const;
|
|
792 virtual int hash() const; // Type specific hashing
|
|
793 const TypeAry *_ary; // Array we point into
|
|
794
|
|
795 public:
|
|
796 // Accessors
|
|
797 ciKlass* klass() const;
|
|
798 const TypeAry* ary() const { return _ary; }
|
|
799 const Type* elem() const { return _ary->_elem; }
|
|
800 const TypeInt* size() const { return _ary->_size; }
|
|
801
|
|
802 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = 0);
|
|
803 // Constant pointer to array
|
|
804 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = 0);
|
|
805
|
|
806 // Convenience
|
|
807 static const TypeAryPtr *make(ciObject* o);
|
|
808
|
|
809 // Return a 'ptr' version of this type
|
|
810 virtual const Type *cast_to_ptr_type(PTR ptr) const;
|
|
811
|
|
812 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
|
|
813
|
|
814 virtual const TypeOopPtr *cast_to_instance(int instance_id) const;
|
|
815
|
|
816 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
|
|
817
|
|
818 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
819 virtual const TypePtr *add_offset( int offset ) const;
|
|
820
|
|
821 virtual const Type *xmeet( const Type *t ) const;
|
|
822 virtual const Type *xdual() const; // Compute dual right now.
|
|
823
|
|
824 // Convenience common pre-built types.
|
|
825 static const TypeAryPtr *RANGE;
|
|
826 static const TypeAryPtr *OOPS;
|
|
827 static const TypeAryPtr *BYTES;
|
|
828 static const TypeAryPtr *SHORTS;
|
|
829 static const TypeAryPtr *CHARS;
|
|
830 static const TypeAryPtr *INTS;
|
|
831 static const TypeAryPtr *LONGS;
|
|
832 static const TypeAryPtr *FLOATS;
|
|
833 static const TypeAryPtr *DOUBLES;
|
|
834 // selects one of the above:
|
|
835 static const TypeAryPtr *get_array_body_type(BasicType elem) {
|
|
836 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
|
|
837 return _array_body_type[elem];
|
|
838 }
|
|
839 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
|
|
840 // sharpen the type of an int which is used as an array size
|
|
841 static const TypeInt* narrow_size_type(const TypeInt* size, BasicType elem);
|
|
842 #ifndef PRODUCT
|
|
843 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
|
|
844 #endif
|
|
845 };
|
|
846
|
|
847 //------------------------------TypeKlassPtr-----------------------------------
|
|
848 // Class of Java Klass pointers
|
|
849 class TypeKlassPtr : public TypeOopPtr {
|
|
850 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
|
|
851
|
|
852 virtual bool eq( const Type *t ) const;
|
|
853 virtual int hash() const; // Type specific hashing
|
|
854
|
|
855 public:
|
|
856 ciSymbol* name() const { return _klass->name(); }
|
|
857
|
|
858 // ptr to klass 'k'
|
|
859 static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
|
|
860 // ptr to klass 'k' with offset
|
|
861 static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
|
|
862 // ptr to klass 'k' or sub-klass
|
|
863 static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
|
|
864
|
|
865 virtual const Type *cast_to_ptr_type(PTR ptr) const;
|
|
866
|
|
867 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
|
|
868
|
|
869 // corresponding pointer to instance, for a given class
|
|
870 const TypeOopPtr* as_instance_type() const;
|
|
871
|
|
872 virtual const TypePtr *add_offset( int offset ) const;
|
|
873 virtual const Type *xmeet( const Type *t ) const;
|
|
874 virtual const Type *xdual() const; // Compute dual right now.
|
|
875
|
|
876 // Convenience common pre-built types.
|
|
877 static const TypeKlassPtr* OBJECT; // Not-null object klass or below
|
|
878 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
|
|
879 #ifndef PRODUCT
|
|
880 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
|
|
881 #endif
|
|
882 };
|
|
883
|
|
884 //------------------------------TypeFunc---------------------------------------
|
|
885 // Class of Array Types
|
|
886 class TypeFunc : public Type {
|
|
887 TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function), _domain(domain), _range(range) {}
|
|
888 virtual bool eq( const Type *t ) const;
|
|
889 virtual int hash() const; // Type specific hashing
|
|
890 virtual bool singleton(void) const; // TRUE if type is a singleton
|
|
891 virtual bool empty(void) const; // TRUE if type is vacuous
|
|
892 public:
|
|
893 // Constants are shared among ADLC and VM
|
|
894 enum { Control = AdlcVMDeps::Control,
|
|
895 I_O = AdlcVMDeps::I_O,
|
|
896 Memory = AdlcVMDeps::Memory,
|
|
897 FramePtr = AdlcVMDeps::FramePtr,
|
|
898 ReturnAdr = AdlcVMDeps::ReturnAdr,
|
|
899 Parms = AdlcVMDeps::Parms
|
|
900 };
|
|
901
|
|
902 const TypeTuple* const _domain; // Domain of inputs
|
|
903 const TypeTuple* const _range; // Range of results
|
|
904
|
|
905 // Accessors:
|
|
906 const TypeTuple* domain() const { return _domain; }
|
|
907 const TypeTuple* range() const { return _range; }
|
|
908
|
|
909 static const TypeFunc *make(ciMethod* method);
|
|
910 static const TypeFunc *make(ciSignature signature, const Type* extra);
|
|
911 static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
|
|
912
|
|
913 virtual const Type *xmeet( const Type *t ) const;
|
|
914 virtual const Type *xdual() const; // Compute dual right now.
|
|
915
|
|
916 BasicType return_type() const;
|
|
917
|
|
918 #ifndef PRODUCT
|
|
919 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
|
|
920 void print_flattened() const; // Print a 'flattened' signature
|
|
921 #endif
|
|
922 // Convenience common pre-built types.
|
|
923 };
|
|
924
|
|
925 //------------------------------accessors--------------------------------------
|
|
926 inline float Type::getf() const {
|
|
927 assert( _base == FloatCon, "Not a FloatCon" );
|
|
928 return ((TypeF*)this)->_f;
|
|
929 }
|
|
930
|
|
931 inline double Type::getd() const {
|
|
932 assert( _base == DoubleCon, "Not a DoubleCon" );
|
|
933 return ((TypeD*)this)->_d;
|
|
934 }
|
|
935
|
|
936 inline const TypeF *Type::is_float_constant() const {
|
|
937 assert( _base == FloatCon, "Not a Float" );
|
|
938 return (TypeF*)this;
|
|
939 }
|
|
940
|
|
941 inline const TypeF *Type::isa_float_constant() const {
|
|
942 return ( _base == FloatCon ? (TypeF*)this : NULL);
|
|
943 }
|
|
944
|
|
945 inline const TypeD *Type::is_double_constant() const {
|
|
946 assert( _base == DoubleCon, "Not a Double" );
|
|
947 return (TypeD*)this;
|
|
948 }
|
|
949
|
|
950 inline const TypeD *Type::isa_double_constant() const {
|
|
951 return ( _base == DoubleCon ? (TypeD*)this : NULL);
|
|
952 }
|
|
953
|
|
954 inline const TypeInt *Type::is_int() const {
|
|
955 assert( _base == Int, "Not an Int" );
|
|
956 return (TypeInt*)this;
|
|
957 }
|
|
958
|
|
959 inline const TypeInt *Type::isa_int() const {
|
|
960 return ( _base == Int ? (TypeInt*)this : NULL);
|
|
961 }
|
|
962
|
|
963 inline const TypeLong *Type::is_long() const {
|
|
964 assert( _base == Long, "Not a Long" );
|
|
965 return (TypeLong*)this;
|
|
966 }
|
|
967
|
|
968 inline const TypeLong *Type::isa_long() const {
|
|
969 return ( _base == Long ? (TypeLong*)this : NULL);
|
|
970 }
|
|
971
|
|
972 inline const TypeTuple *Type::is_tuple() const {
|
|
973 assert( _base == Tuple, "Not a Tuple" );
|
|
974 return (TypeTuple*)this;
|
|
975 }
|
|
976
|
|
977 inline const TypeAry *Type::is_ary() const {
|
|
978 assert( _base == Array , "Not an Array" );
|
|
979 return (TypeAry*)this;
|
|
980 }
|
|
981
|
|
982 inline const TypePtr *Type::is_ptr() const {
|
|
983 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
|
|
984 assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
|
|
985 return (TypePtr*)this;
|
|
986 }
|
|
987
|
|
988 inline const TypePtr *Type::isa_ptr() const {
|
|
989 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
|
|
990 return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
|
|
991 }
|
|
992
|
|
993 inline const TypeOopPtr *Type::is_oopptr() const {
|
|
994 // OopPtr is the first and KlassPtr the last, with no non-oops between.
|
|
995 assert(_base >= OopPtr && _base <= KlassPtr, "Not a Java pointer" ) ;
|
|
996 return (TypeOopPtr*)this;
|
|
997 }
|
|
998
|
|
999 inline const TypeOopPtr *Type::isa_oopptr() const {
|
|
1000 // OopPtr is the first and KlassPtr the last, with no non-oops between.
|
|
1001 return (_base >= OopPtr && _base <= KlassPtr) ? (TypeOopPtr*)this : NULL;
|
|
1002 }
|
|
1003
|
|
1004 inline const TypeRawPtr *Type::is_rawptr() const {
|
|
1005 assert( _base == RawPtr, "Not a raw pointer" );
|
|
1006 return (TypeRawPtr*)this;
|
|
1007 }
|
|
1008
|
|
1009 inline const TypeInstPtr *Type::isa_instptr() const {
|
|
1010 return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
|
|
1011 }
|
|
1012
|
|
1013 inline const TypeInstPtr *Type::is_instptr() const {
|
|
1014 assert( _base == InstPtr, "Not an object pointer" );
|
|
1015 return (TypeInstPtr*)this;
|
|
1016 }
|
|
1017
|
|
1018 inline const TypeAryPtr *Type::isa_aryptr() const {
|
|
1019 return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
|
|
1020 }
|
|
1021
|
|
1022 inline const TypeAryPtr *Type::is_aryptr() const {
|
|
1023 assert( _base == AryPtr, "Not an array pointer" );
|
|
1024 return (TypeAryPtr*)this;
|
|
1025 }
|
|
1026
|
|
1027 inline const TypeKlassPtr *Type::isa_klassptr() const {
|
|
1028 return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
|
|
1029 }
|
|
1030
|
|
1031 inline const TypeKlassPtr *Type::is_klassptr() const {
|
|
1032 assert( _base == KlassPtr, "Not a klass pointer" );
|
|
1033 return (TypeKlassPtr*)this;
|
|
1034 }
|
|
1035
|
|
1036 inline bool Type::is_floatingpoint() const {
|
|
1037 if( (_base == FloatCon) || (_base == FloatBot) ||
|
|
1038 (_base == DoubleCon) || (_base == DoubleBot) )
|
|
1039 return true;
|
|
1040 return false;
|
|
1041 }
|
|
1042
|
|
1043
|
|
1044 // ===============================================================
|
|
1045 // Things that need to be 64-bits in the 64-bit build but
|
|
1046 // 32-bits in the 32-bit build. Done this way to get full
|
|
1047 // optimization AND strong typing.
|
|
1048 #ifdef _LP64
|
|
1049
|
|
1050 // For type queries and asserts
|
|
1051 #define is_intptr_t is_long
|
|
1052 #define isa_intptr_t isa_long
|
|
1053 #define find_intptr_t_type find_long_type
|
|
1054 #define find_intptr_t_con find_long_con
|
|
1055 #define TypeX TypeLong
|
|
1056 #define Type_X Type::Long
|
|
1057 #define TypeX_X TypeLong::LONG
|
|
1058 #define TypeX_ZERO TypeLong::ZERO
|
|
1059 // For 'ideal_reg' machine registers
|
|
1060 #define Op_RegX Op_RegL
|
|
1061 // For phase->intcon variants
|
|
1062 #define MakeConX longcon
|
|
1063 #define ConXNode ConLNode
|
|
1064 // For array index arithmetic
|
|
1065 #define MulXNode MulLNode
|
|
1066 #define AndXNode AndLNode
|
|
1067 #define OrXNode OrLNode
|
|
1068 #define CmpXNode CmpLNode
|
|
1069 #define SubXNode SubLNode
|
|
1070 #define LShiftXNode LShiftLNode
|
|
1071 // For object size computation:
|
|
1072 #define AddXNode AddLNode
|
|
1073 // For card marks and hashcodes
|
|
1074 #define URShiftXNode URShiftLNode
|
|
1075 // Opcodes
|
|
1076 #define Op_LShiftX Op_LShiftL
|
|
1077 #define Op_AndX Op_AndL
|
|
1078 #define Op_AddX Op_AddL
|
|
1079 #define Op_SubX Op_SubL
|
|
1080 // conversions
|
|
1081 #define ConvI2X(x) ConvI2L(x)
|
|
1082 #define ConvL2X(x) (x)
|
|
1083 #define ConvX2I(x) ConvL2I(x)
|
|
1084 #define ConvX2L(x) (x)
|
|
1085
|
|
1086 #else
|
|
1087
|
|
1088 // For type queries and asserts
|
|
1089 #define is_intptr_t is_int
|
|
1090 #define isa_intptr_t isa_int
|
|
1091 #define find_intptr_t_type find_int_type
|
|
1092 #define find_intptr_t_con find_int_con
|
|
1093 #define TypeX TypeInt
|
|
1094 #define Type_X Type::Int
|
|
1095 #define TypeX_X TypeInt::INT
|
|
1096 #define TypeX_ZERO TypeInt::ZERO
|
|
1097 // For 'ideal_reg' machine registers
|
|
1098 #define Op_RegX Op_RegI
|
|
1099 // For phase->intcon variants
|
|
1100 #define MakeConX intcon
|
|
1101 #define ConXNode ConINode
|
|
1102 // For array index arithmetic
|
|
1103 #define MulXNode MulINode
|
|
1104 #define AndXNode AndINode
|
|
1105 #define OrXNode OrINode
|
|
1106 #define CmpXNode CmpINode
|
|
1107 #define SubXNode SubINode
|
|
1108 #define LShiftXNode LShiftINode
|
|
1109 // For object size computation:
|
|
1110 #define AddXNode AddINode
|
|
1111 // For card marks and hashcodes
|
|
1112 #define URShiftXNode URShiftINode
|
|
1113 // Opcodes
|
|
1114 #define Op_LShiftX Op_LShiftI
|
|
1115 #define Op_AndX Op_AndI
|
|
1116 #define Op_AddX Op_AddI
|
|
1117 #define Op_SubX Op_SubI
|
|
1118 // conversions
|
|
1119 #define ConvI2X(x) (x)
|
|
1120 #define ConvL2X(x) ConvL2I(x)
|
|
1121 #define ConvX2I(x) (x)
|
|
1122 #define ConvX2L(x) ConvI2L(x)
|
|
1123
|
|
1124 #endif
|