1 /*
2 * Copyright (c) 1997, 2026, 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_OPTO_TYPE_HPP
26 #define SHARE_OPTO_TYPE_HPP
27
28 #include "ci/ciInlineKlass.hpp"
29 #include "opto/adlcVMDeps.hpp"
30 #include "opto/compile.hpp"
31 #include "opto/rangeinference.hpp"
32
33 // Portions of code courtesy of Clifford Click
34
35 // Optimization - Graph Style
36
37
38 // This class defines a Type lattice. The lattice is used in the constant
39 // propagation algorithms, and for some type-checking of the iloc code.
40 // Basic types include RSD's (lower bound, upper bound, stride for integers),
41 // float & double precision constants, sets of data-labels and code-labels.
42 // The complete lattice is described below. Subtypes have no relationship to
43 // up or down in the lattice; that is entirely determined by the behavior of
44 // the MEET/JOIN functions.
45
46 class Dict;
47 class Type;
48 class TypeD;
49 class TypeF;
50 class TypeH;
51 class TypeInteger;
52 class TypeInt;
53 class TypeLong;
54 class TypeNarrowPtr;
55 class TypeNarrowOop;
56 class TypeNarrowKlass;
57 class TypeAry;
58 class TypeTuple;
59 class TypeVect;
60 class TypeVectA;
61 class TypeVectS;
62 class TypeVectD;
63 class TypeVectX;
64 class TypeVectY;
65 class TypeVectZ;
66 class TypePVectMask;
67 class TypePtr;
68 class TypeRawPtr;
69 class TypeOopPtr;
70 class TypeInstPtr;
71 class TypeAryPtr;
72 class TypeKlassPtr;
73 class TypeInstKlassPtr;
74 class TypeAryKlassPtr;
75 class TypeMetadataPtr;
76 class VerifyMeet;
77
78 template <class T, class U>
79 class TypeIntPrototype;
80
81 //------------------------------Type-------------------------------------------
82 // Basic Type object, represents a set of primitive Values.
83 // Types are hash-cons'd into a private class dictionary, so only one of each
84 // different kind of Type exists. Types are never modified after creation, so
85 // all their interesting fields are constant.
86 class Type {
87
88 public:
89 enum TYPES {
90 Bad=0, // Type check
91 Control, // Control of code (not in lattice)
92 Top, // Top of the lattice
93 Int, // Integer range (lo-hi)
94 Long, // Long integer range (lo-hi)
95 Half, // Placeholder half of doubleword
96 NarrowOop, // Compressed oop pointer
97 NarrowKlass, // Compressed klass pointer
98
99 Tuple, // Method signature or object layout
100 Array, // Array types
101
102 Interfaces, // Set of implemented interfaces for oop types
103
104 VectorMask, // Vector predicate/mask type
105 VectorA, // (Scalable) Vector types for vector length agnostic
106 VectorS, // 32bit Vector types
107 VectorD, // 64bit Vector types
108 VectorX, // 128bit Vector types
109 VectorY, // 256bit Vector types
110 VectorZ, // 512bit Vector types
111
112 AnyPtr, // Any old raw, klass, inst, or array pointer
113 RawPtr, // Raw (non-oop) pointers
114 OopPtr, // Any and all Java heap entities
115 InstPtr, // Instance pointers (non-array objects)
116 AryPtr, // Array pointers
117 // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
118
119 MetadataPtr, // Generic metadata
120 KlassPtr, // Klass pointers
121 InstKlassPtr,
122 AryKlassPtr,
123
124 Function, // Function signature
125 Abio, // Abstract I/O
126 Return_Address, // Subroutine return address
127 Memory, // Abstract store
128 HalfFloatTop, // No float value
129 HalfFloatCon, // Floating point constant
130 HalfFloatBot, // Any float value
131 FloatTop, // No float value
132 FloatCon, // Floating point constant
133 FloatBot, // Any float value
134 DoubleTop, // No double value
135 DoubleCon, // Double precision constant
136 DoubleBot, // Any double value
137 Bottom, // Bottom of lattice
138 lastype // Bogus ending type (not in lattice)
139 };
140
141 // Signal values for offsets from a base pointer
142 enum OFFSET_SIGNALS {
143 OffsetTop = -2000000000, // undefined offset
144 OffsetBot = -2000000001 // any possible offset
145 };
146
147 class Offset {
148 private:
149 int _offset;
150
151 public:
152 explicit Offset(int offset) : _offset(offset) {}
153
154 const Offset meet(const Offset other) const;
155 const Offset dual() const;
156 const Offset add(intptr_t offset) const;
157 bool operator==(const Offset& other) const {
158 return _offset == other._offset;
159 }
160 bool operator!=(const Offset& other) const {
161 return _offset != other._offset;
162 }
163 int get() const { return _offset; }
164
165 void dump2(outputStream *st) const;
166
167 static const Offset top;
168 static const Offset bottom;
169 };
170
171 // Min and max WIDEN values.
172 enum WIDEN {
173 WidenMin = 0,
174 WidenMax = 3
175 };
176
177 private:
178 typedef struct {
179 TYPES dual_type;
180 BasicType basic_type;
181 const char* msg;
182 bool isa_oop;
183 uint ideal_reg;
184 } TypeInfo;
185
186 // Dictionary of types shared among compilations.
187 static Dict* _shared_type_dict;
188 static const TypeInfo _type_info[];
189
190 static int uhash( const Type *const t );
191 // Structural equality check. Assumes that equals() has already compared
192 // the _base types and thus knows it can cast 't' appropriately.
193 virtual bool eq( const Type *t ) const;
194
195 // Top-level hash-table of types
196 static Dict *type_dict() {
197 return Compile::current()->type_dict();
198 }
199
200 // DUAL operation: reflect around lattice centerline. Used instead of
201 // join to ensure my lattice is symmetric up and down. Dual is computed
202 // lazily, on demand, and cached in _dual.
203 const Type *_dual; // Cached dual value
204
205
206 const Type *meet_helper(const Type *t, bool include_speculative) const;
207 void check_symmetrical(const Type* t, const Type* mt, const VerifyMeet& verify) const NOT_DEBUG_RETURN;
208
209 protected:
210 // Each class of type is also identified by its base.
211 const TYPES _base; // Enum of Types type
212
213 Type( TYPES t ) : _dual(nullptr), _base(t) {} // Simple types
214 // ~Type(); // Use fast deallocation
215 const Type *hashcons(); // Hash-cons the type
216 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
217 const Type *join_helper(const Type *t, bool include_speculative) const {
218 assert_type_verify_empty();
219 return dual()->meet_helper(t->dual(), include_speculative)->dual();
220 }
221
222 void assert_type_verify_empty() const NOT_DEBUG_RETURN;
223
224 public:
225
226 inline void* operator new( size_t x ) throw() {
227 Compile* compile = Compile::current();
228 compile->set_type_last_size(x);
229 return compile->type_arena()->AmallocWords(x);
230 }
231 inline void operator delete( void* ptr ) {
232 Compile* compile = Compile::current();
233 compile->type_arena()->Afree(ptr,compile->type_last_size());
234 }
235
236 // Initialize the type system for a particular compilation.
237 static void Initialize(Compile* compile);
238
239 // Initialize the types shared by all compilations.
240 static void Initialize_shared(Compile* compile);
241
242 TYPES base() const {
243 assert(_base > Bad && _base < lastype, "sanity");
244 return _base;
245 }
246
247 // Create a new hash-consd type
248 static const Type *make(enum TYPES);
249 // Test for equivalence of types
250 static bool equals(const Type* t1, const Type* t2);
251 // Test for higher or equal in lattice
252 // Variant that drops the speculative part of the types
253 bool higher_equal(const Type* t) const {
254 return equals(meet(t), t->remove_speculative());
255 }
256 // Variant that keeps the speculative part of the types
257 bool higher_equal_speculative(const Type* t) const {
258 return equals(meet_speculative(t), t);
259 }
260
261 // MEET operation; lower in lattice.
262 // Variant that drops the speculative part of the types
263 const Type *meet(const Type *t) const {
264 return meet_helper(t, false);
265 }
266 // Variant that keeps the speculative part of the types
267 const Type *meet_speculative(const Type *t) const {
268 return meet_helper(t, true)->cleanup_speculative();
269 }
270 // WIDEN: 'widens' for Ints and other range types
271 virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
272 // NARROW: complement for widen, used by pessimistic phases
273 virtual const Type *narrow( const Type *old ) const { return this; }
274
275 // DUAL operation: reflect around lattice centerline. Used instead of
276 // join to ensure my lattice is symmetric up and down.
277 const Type *dual() const { return _dual; }
278
279 // Compute meet dependent on base type
280 virtual const Type *xmeet( const Type *t ) const;
281 virtual const Type *xdual() const; // Compute dual right now.
282
283 // JOIN operation; higher in lattice. Done by finding the dual of the
284 // meet of the dual of the 2 inputs.
285 // Variant that drops the speculative part of the types
286 const Type *join(const Type *t) const {
287 return join_helper(t, false);
288 }
289 // Variant that keeps the speculative part of the types
290 const Type *join_speculative(const Type *t) const {
291 return join_helper(t, true)->cleanup_speculative();
292 }
293
294 // Modified version of JOIN adapted to the needs Node::Value.
295 // Normalizes all empty values to TOP. Does not kill _widen bits.
296 // Variant that drops the speculative part of the types
297 const Type *filter(const Type *kills) const {
298 return filter_helper(kills, false);
299 }
300 // Variant that keeps the speculative part of the types
301 const Type *filter_speculative(const Type *kills) const {
302 return filter_helper(kills, true)->cleanup_speculative();
303 }
304
305 // Returns true if this pointer points at memory which contains a
306 // compressed oop references.
307 bool is_ptr_to_narrowoop() const;
308 bool is_ptr_to_narrowklass() const;
309
310 // Convenience access
311 short geth() const;
312 virtual float getf() const;
313 double getd() const;
314
315 // This has the same semantics as std::dynamic_cast<TypeClass*>(this)
316 template <typename TypeClass>
317 const TypeClass* try_cast() const;
318
319 const TypeInt *is_int() const;
320 const TypeInt *isa_int() const; // Returns null if not an Int
321 const TypeInteger* is_integer(BasicType bt) const;
322 const TypeInteger* isa_integer(BasicType bt) const;
323 const TypeLong *is_long() const;
324 const TypeLong *isa_long() const; // Returns null if not a Long
325 const TypeD *isa_double() const; // Returns null if not a Double{Top,Con,Bot}
326 const TypeD *is_double_constant() const; // Asserts it is a DoubleCon
327 const TypeD *isa_double_constant() const; // Returns null if not a DoubleCon
328 const TypeH *isa_half_float() const; // Returns null if not a HalfFloat{Top,Con,Bot}
329 const TypeH *is_half_float_constant() const; // Asserts it is a HalfFloatCon
330 const TypeH *isa_half_float_constant() const; // Returns null if not a HalfFloatCon
331 const TypeF *isa_float() const; // Returns null if not a Float{Top,Con,Bot}
332 const TypeF *is_float_constant() const; // Asserts it is a FloatCon
333 const TypeF *isa_float_constant() const; // Returns null if not a FloatCon
334 const TypeTuple *is_tuple() const; // Collection of fields, NOT a pointer
335 const TypeAry *is_ary() const; // Array, NOT array pointer
336 const TypeAry *isa_ary() const; // Returns null of not ary
337 const TypeVect *is_vect() const; // Vector
338 const TypeVect *isa_vect() const; // Returns null if not a Vector
339 const TypePVectMask *is_pvectmask() const; // Predicate/Mask Vector
340 const TypePVectMask *isa_pvectmask() const; // Returns null if not a Vector Predicate/Mask
341 const TypePtr *is_ptr() const; // Asserts it is a ptr type
342 const TypePtr *isa_ptr() const; // Returns null if not ptr type
343 const TypeRawPtr *isa_rawptr() const; // NOT Java oop
344 const TypeRawPtr *is_rawptr() const; // Asserts is rawptr
345 const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer
346 const TypeNarrowOop *isa_narrowoop() const; // Returns null if not oop ptr type
347 const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
348 const TypeNarrowKlass *isa_narrowklass() const;// Returns null if not oop ptr type
349 const TypeOopPtr *isa_oopptr() const; // Returns null if not oop ptr type
350 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer
351 const TypeInstPtr *isa_instptr() const; // Returns null if not InstPtr
352 const TypeInstPtr *is_instptr() const; // Instance
353 const TypeAryPtr *isa_aryptr() const; // Returns null if not AryPtr
354 const TypeAryPtr *is_aryptr() const; // Array oop
355
356 template <typename TypeClass>
357 const TypeClass* cast() const;
358
359 const TypeMetadataPtr *isa_metadataptr() const; // Returns null if not oop ptr type
360 const TypeMetadataPtr *is_metadataptr() const; // Java-style GC'd pointer
361 const TypeKlassPtr *isa_klassptr() const; // Returns null if not KlassPtr
362 const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr
363 const TypeInstKlassPtr *isa_instklassptr() const; // Returns null if not IntKlassPtr
364 const TypeInstKlassPtr *is_instklassptr() const; // assert if not IntKlassPtr
365 const TypeAryKlassPtr *isa_aryklassptr() const; // Returns null if not AryKlassPtr
366 const TypeAryKlassPtr *is_aryklassptr() const; // assert if not AryKlassPtr
367
368 virtual bool is_finite() const; // Has a finite value
369 virtual bool is_nan() const; // Is not a number (NaN)
370
371 bool is_inlinetypeptr() const;
372 virtual ciInlineKlass* inline_klass() const;
373
374 // Returns this ptr type or the equivalent ptr type for this compressed pointer.
375 const TypePtr* make_ptr() const;
376
377 // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
378 // Asserts if the underlying type is not an oopptr or narrowoop.
379 const TypeOopPtr* make_oopptr() const;
380
381 // Returns this compressed pointer or the equivalent compressed version
382 // of this pointer type.
383 const TypeNarrowOop* make_narrowoop() const;
384
385 // Returns this compressed klass pointer or the equivalent
386 // compressed version of this pointer type.
387 const TypeNarrowKlass* make_narrowklass() const;
388
389 // Special test for register pressure heuristic
390 bool is_floatingpoint() const; // True if Float or Double base type
391
392 // Do you have memory, directly or through a tuple?
393 bool has_memory( ) const;
394
395 // TRUE if type is a singleton
396 virtual bool singleton(void) const;
397
398 // TRUE if type is above the lattice centerline, and is therefore vacuous
399 virtual bool empty(void) const;
400
401 // Return a hash for this type. The hash function is public so ConNode
402 // (constants) can hash on their constant, which is represented by a Type.
403 virtual uint hash() const;
404
405 // Map ideal registers (machine types) to ideal types
406 static const Type *mreg2type[];
407
408 // Printing, statistics
409 #ifndef PRODUCT
410 void dump_on(outputStream *st) const;
411 void dump() const {
412 dump_on(tty);
413 }
414 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
415 static void dump_stats();
416 // Groups of types, for debugging and visualization only.
417 enum class Category {
418 Data,
419 Memory,
420 Mixed, // Tuples with types of different categories.
421 Control,
422 Other, // {Type::Top, Type::Abio, Type::Bottom}.
423 Undef // {Type::Bad, Type::lastype}, for completeness.
424 };
425 // Return the category of this type.
426 Category category() const;
427 // Check recursively in tuples.
428 bool has_category(Category cat) const;
429
430 static const char* str(const Type* t);
431 #endif // !PRODUCT
432 void typerr(const Type *t) const; // Mixing types error
433
434 // Create basic type
435 static const Type* get_const_basic_type(BasicType type) {
436 assert((uint)type <= T_CONFLICT && _const_basic_type[type] != nullptr, "bad type");
437 return _const_basic_type[type];
438 }
439
440 // For two instance arrays of same dimension, return the base element types.
441 // Otherwise or if the arrays have different dimensions, return null.
442 static void get_arrays_base_elements(const Type *a1, const Type *a2,
443 const TypeInstPtr **e1, const TypeInstPtr **e2);
444
445 // Mapping to the array element's basic type.
446 BasicType array_element_basic_type() const;
447
448 enum InterfaceHandling {
449 trust_interfaces,
450 ignore_interfaces
451 };
452 // Create standard type for a ciType:
453 static const Type* get_const_type(ciType* type, InterfaceHandling interface_handling = ignore_interfaces);
454
455 // Create standard zero value:
456 static const Type* get_zero_type(BasicType type) {
457 assert((uint)type <= T_CONFLICT && _zero_type[type] != nullptr, "bad type");
458 return _zero_type[type];
459 }
460
461 // Report if this is a zero value (not top).
462 bool is_zero_type() const {
463 BasicType type = basic_type();
464 if (type == T_VOID || type >= T_CONFLICT)
465 return false;
466 else
467 return (this == _zero_type[type]);
468 }
469
470 // Convenience common pre-built types.
471 static const Type *ABIO;
472 static const Type *BOTTOM;
473 static const Type *CONTROL;
474 static const Type *DOUBLE;
475 static const Type *FLOAT;
476 static const Type *HALF_FLOAT;
477 static const Type *HALF;
478 static const Type *MEMORY;
479 static const Type *MULTI;
480 static const Type *RETURN_ADDRESS;
481 static const Type *TOP;
482
483 // Mapping from compiler type to VM BasicType
484 BasicType basic_type() const { return _type_info[_base].basic_type; }
485 uint ideal_reg() const { return _type_info[_base].ideal_reg; }
486 const char* msg() const { return _type_info[_base].msg; }
487 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; }
488
489 // Mapping from CI type system to compiler type:
490 static const Type* get_typeflow_type(ciType* type);
491
492 static const Type* make_from_constant(ciConstant constant,
493 bool require_constant = false,
494 int stable_dimension = 0,
495 bool is_narrow = false,
496 bool is_autobox_cache = false);
497
498 static const Type* make_constant_from_field(ciInstance* holder,
499 int off,
500 bool is_unsigned_load,
501 BasicType loadbt);
502
503 static const Type* make_constant_from_field(ciField* field,
504 ciInstance* holder,
505 BasicType loadbt,
506 bool is_unsigned_load);
507
508 static const Type* make_constant_from_array_element(ciArray* array,
509 int off,
510 int field_offset,
511 int stable_dimension,
512 BasicType loadbt,
513 bool is_unsigned_load);
514
515 // Speculative type helper methods. See TypePtr.
516 virtual const TypePtr* speculative() const { return nullptr; }
517 virtual ciKlass* speculative_type() const { return nullptr; }
518 virtual ciKlass* speculative_type_not_null() const { return nullptr; }
519 virtual bool speculative_maybe_null() const { return true; }
520 virtual bool speculative_always_null() const { return true; }
521 virtual const Type* remove_speculative() const { return this; }
522 virtual const Type* cleanup_speculative() const { return this; }
523 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != nullptr; }
524 virtual bool would_improve_ptr(ProfilePtrKind ptr_kind) const { return ptr_kind == ProfileAlwaysNull || ptr_kind == ProfileNeverNull; }
525 const Type* maybe_remove_speculative(bool include_speculative) const;
526
527 virtual bool maybe_null() const { return true; }
528 virtual bool is_known_instance() const { return false; }
529
530 private:
531 // support arrays
532 static const Type* _zero_type[T_CONFLICT+1];
533 static const Type* _const_basic_type[T_CONFLICT+1];
534 };
535
536 //------------------------------TypeF------------------------------------------
537 // Class of Float-Constant Types.
538 class TypeF : public Type {
539 TypeF( float f ) : Type(FloatCon), _f(f) {};
540 public:
541 virtual bool eq( const Type *t ) const;
542 virtual uint hash() const; // Type specific hashing
543 virtual bool singleton(void) const; // TRUE if type is a singleton
544 virtual bool empty(void) const; // TRUE if type is vacuous
545 public:
546 const float _f; // Float constant
547
548 static const TypeF *make(float f);
549
550 virtual bool is_finite() const; // Has a finite value
551 virtual bool is_nan() const; // Is not a number (NaN)
552
553 virtual const Type *xmeet( const Type *t ) const;
554 virtual const Type *xdual() const; // Compute dual right now.
555 // Convenience common pre-built types.
556 static const TypeF *MAX;
557 static const TypeF *MIN;
558 static const TypeF *ZERO; // positive zero only
559 static const TypeF *ONE;
560 static const TypeF *POS_INF;
561 static const TypeF *NEG_INF;
562 #ifndef PRODUCT
563 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
564 #endif
565 };
566
567 // Class of Half Float-Constant Types.
568 class TypeH : public Type {
569 TypeH(short f) : Type(HalfFloatCon), _f(f) {};
570 public:
571 virtual bool eq(const Type* t) const;
572 virtual uint hash() const; // Type specific hashing
573 virtual bool singleton(void) const; // TRUE if type is a singleton
574 virtual bool empty(void) const; // TRUE if type is vacuous
575 public:
576 const short _f; // Half Float constant
577
578 static const TypeH* make(float f);
579 static const TypeH* make(short f);
580
581 virtual bool is_finite() const; // Has a finite value
582 virtual bool is_nan() const; // Is not a number (NaN)
583
584 virtual float getf() const;
585 virtual const Type* xmeet(const Type* t) const;
586 virtual const Type* xdual() const; // Compute dual right now.
587 // Convenience common pre-built types.
588 static const TypeH* MAX;
589 static const TypeH* MIN;
590 static const TypeH* ZERO; // positive zero only
591 static const TypeH* ONE;
592 static const TypeH* POS_INF;
593 static const TypeH* NEG_INF;
594 #ifndef PRODUCT
595 virtual void dump2(Dict &d, uint depth, outputStream* st) const;
596 #endif
597 };
598
599 //------------------------------TypeD------------------------------------------
600 // Class of Double-Constant Types.
601 class TypeD : public Type {
602 TypeD( double d ) : Type(DoubleCon), _d(d) {};
603 public:
604 virtual bool eq( const Type *t ) const;
605 virtual uint hash() const; // Type specific hashing
606 virtual bool singleton(void) const; // TRUE if type is a singleton
607 virtual bool empty(void) const; // TRUE if type is vacuous
608 public:
609 const double _d; // Double constant
610
611 static const TypeD *make(double d);
612
613 virtual bool is_finite() const; // Has a finite value
614 virtual bool is_nan() const; // Is not a number (NaN)
615
616 virtual const Type *xmeet( const Type *t ) const;
617 virtual const Type *xdual() const; // Compute dual right now.
618 // Convenience common pre-built types.
619 static const TypeD *MAX;
620 static const TypeD *MIN;
621 static const TypeD *ZERO; // positive zero only
622 static const TypeD *ONE;
623 static const TypeD *POS_INF;
624 static const TypeD *NEG_INF;
625 #ifndef PRODUCT
626 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
627 #endif
628 };
629
630 class TypeInteger : public Type {
631 protected:
632 TypeInteger(TYPES t, int w, bool dual) : Type(t), _is_dual(dual), _widen(w) {}
633
634 // Denote that a set is a dual set.
635 // Dual sets are only used to compute the join of 2 sets, and not used
636 // outside.
637 const bool _is_dual;
638
639 public:
640 const short _widen; // Limit on times we widen this sucker
641
642 virtual jlong hi_as_long() const = 0;
643 virtual jlong lo_as_long() const = 0;
644 jlong get_con_as_long(BasicType bt) const;
645 bool is_con() const { return lo_as_long() == hi_as_long(); }
646 virtual short widen_limit() const { return _widen; }
647
648 static const TypeInteger* make(jlong lo, jlong hi, int w, BasicType bt);
649 static const TypeInteger* make(jlong con, BasicType bt);
650
651 static const TypeInteger* bottom(BasicType type);
652 static const TypeInteger* zero(BasicType type);
653 static const TypeInteger* one(BasicType type);
654 static const TypeInteger* minus_1(BasicType type);
655 };
656
657 /**
658 * Definition:
659 *
660 * A TypeInt represents a set of non-empty jint values. A jint v is an element
661 * of a TypeInt iff:
662 *
663 * v >= _lo && v <= _hi &&
664 * juint(v) >= _ulo && juint(v) <= _uhi &&
665 * _bits.is_satisfied_by(v)
666 *
667 * Multiple sets of parameters can represent the same set.
668 * E.g: consider 2 TypeInt t1, t2
669 *
670 * t1._lo = 2, t1._hi = 7, t1._ulo = 0, t1._uhi = 5, t1._bits._zeros = 0x00000000, t1._bits._ones = 0x1
671 * t2._lo = 3, t2._hi = 5, t2._ulo = 3, t2._uhi = 5, t2._bits._zeros = 0xFFFFFFF8, t2._bits._ones = 0x1
672 *
673 * Then, t1 and t2 both represent the set {3, 5}. We can also see that the
674 * constraints of t2 are the tightest possible. I.e there exists no TypeInt t3
675 * which also represents {3, 5} such that any of these would be true:
676 *
677 * 1) t3._lo > t2._lo
678 * 2) t3._hi < t2._hi
679 * 3) t3._ulo > t2._ulo
680 * 4) t3._uhi < t2._uhi
681 * 5) (t3._bits._zeros &~ t2._bis._zeros) != 0
682 * 6) (t3._bits._ones &~ t2._bits._ones) != 0
683 *
684 * The 5-th condition mean that the subtraction of the bitsets represented by
685 * t3._bits._zeros and t2._bits._zeros is not empty, which means that the
686 * bits in t3._bits._zeros is not a subset of those in t2._bits._zeros, the
687 * same applies to _bits._ones
688 *
689 * To simplify reasoning about the types in optimizations, we canonicalize
690 * every TypeInt to its tightest form, already at construction. E.g a TypeInt
691 * t with t._lo < 0 will definitely contain negative values. It also makes it
692 * trivial to determine if a TypeInt instance is a subset of another.
693 *
694 * Lemmas:
695 *
696 * 1. Since every TypeInt instance is non-empty and canonicalized, all the
697 * bounds must also be elements of such TypeInt. Or else, we can tighten the
698 * bounds by narrowing it by one, which contradicts the assumption of the
699 * TypeInt being canonical.
700 *
701 * 2.
702 * 2.1. _lo <= jint(_ulo)
703 * 2.2. _lo <= _hi
704 * 2.3. _lo <= jint(_uhi)
705 * 2.4. _ulo <= juint(_lo)
706 * 2.5. _ulo <= juint(_hi)
707 * 2.6. _ulo <= _uhi
708 * 2.7. _hi >= _lo
709 * 2.8. _hi >= jint(_ulo)
710 * 2.9. _hi >= jint(_uhi)
711 * 2.10. _uhi >= juint(_lo)
712 * 2.11. _uhi >= _ulo
713 * 2.12. _uhi >= juint(_hi)
714 *
715 * Proof of lemma 2:
716 *
717 * 2.1. _lo <= jint(_ulo):
718 * According the lemma 1, _ulo is an element of the TypeInt, so in the
719 * signed domain, it must not be less than the smallest element of that
720 * TypeInt, which is _lo. Which means that _lo <= _ulo in the signed
721 * domain, or in a more programmatical way, _lo <= jint(_ulo).
722 * 2.2. _lo <= _hi:
723 * According the lemma 1, _hi is an element of the TypeInt, so in the
724 * signed domain, it must not be less than the smallest element of that
725 * TypeInt, which is _lo. Which means that _lo <= _hi.
726 *
727 * The other inequalities can be proved in a similar manner.
728 *
729 * 3. Given 2 jint values x, y where either both >= 0 or both < 0. Then:
730 *
731 * x <= y iff juint(x) <= juint(y)
732 * I.e. x <= y in the signed domain iff x <= y in the unsigned domain
733 *
734 * 4. Either _lo == jint(_ulo) and _hi == jint(_uhi), or each element of a
735 * TypeInt lies in either interval [_lo, jint(_uhi)] or [jint(_ulo), _hi]
736 * (note that these intervals are disjoint in this case).
737 *
738 * Proof of lemma 4:
739 *
740 * For a TypeInt t, there are 3 possible cases:
741 *
742 * a. t._lo >= 0, we have:
743 *
744 * 0 <= t_lo <= jint(t._ulo) (lemma 2.1)
745 * juint(t._lo) <= juint(jint(t._ulo)) (lemma 3)
746 * == t._ulo (juint(jint(v)) == v with juint v)
747 * <= juint(t._lo) (lemma 2.4)
748 *
749 * Which means that t._lo == jint(t._ulo).
750 *
751 * Furthermore,
752 *
753 * 0 <= t._lo <= t._hi (lemma 2.2)
754 * 0 <= t._lo <= jint(t._uhi) (lemma 2.3)
755 * t._hi >= jint(t._uhi) (lemma 2.9)
756 *
757 * juint(t._hi) >= juint(jint(t._uhi)) (lemma 3)
758 * == t._uhi (juint(jint(v)) == v with juint v)
759 * >= juint(t._hi) (lemma 2.12)
760 *
761 * Which means that t._hi == jint(t._uhi).
762 * In this case, t._lo == jint(t._ulo) and t._hi == jint(t._uhi)
763 *
764 * b. t._hi < 0. Similarly, we can conclude that:
765 * t._lo == jint(t._ulo) and t._hi == jint(t._uhi)
766 *
767 * c. t._lo < 0, t._hi >= 0.
768 *
769 * Since t._ulo <= juint(t._hi) (lemma 2.5), we must have jint(t._ulo) >= 0
770 * because all negative values is larger than all non-negative values in the
771 * unsigned domain.
772 *
773 * Since t._uhi >= juint(t._lo) (lemma 2.10), we must have jint(t._uhi) < 0
774 * similar to the reasoning above.
775 *
776 * In this case, each element of t belongs to either [t._lo, jint(t._uhi)] or
777 * [jint(t._ulo), t._hi].
778 *
779 * Below is an illustration of the TypeInt in this case, the intervals that
780 * the elements can be in are marked using the = symbol. Note how the
781 * negative range in the signed domain wrap around in the unsigned domain.
782 *
783 * Signed:
784 * -----lo=========uhi---------0--------ulo==========hi-----
785 * Unsigned:
786 * 0--------ulo==========hi----------lo=========uhi---------
787 *
788 * This property is useful for our analysis of TypeInt values. Additionally,
789 * it can be seen that _lo and jint(_uhi) are both < 0 or both >= 0, and the
790 * same applies to jint(_ulo) and _hi.
791 *
792 * We call [_lo, jint(_uhi)] and [jint(_ulo), _hi] "simple intervals". Then,
793 * a TypeInt consists of 2 simple intervals, each of which has its bounds
794 * being both >= 0 or both < 0. If both simple intervals lie in the same half
795 * of the integer domain, they must be the same (i.e _lo == jint(_ulo) and
796 * _hi == jint(_uhi)). Otherwise, [_lo, jint(_uhi)] must lie in the negative
797 * half and [jint(_ulo), _hi] must lie in the non-negative half of the signed
798 * domain (equivalently, [_lo, jint(_uhi)] must lie in the upper half and
799 * [jint(_ulo), _hi] must lie in the lower half of the unsigned domain).
800 */
801 class TypeInt : public TypeInteger {
802 private:
803 TypeInt(const TypeIntPrototype<jint, juint>& t, int w, bool dual);
804 static const Type* make_or_top(const TypeIntPrototype<jint, juint>& t, int widen, bool dual);
805
806 friend class TypeIntHelper;
807
808 protected:
809 virtual const Type* filter_helper(const Type* kills, bool include_speculative) const;
810
811 public:
812 typedef jint NativeType;
813 virtual bool eq(const Type* t) const;
814 virtual uint hash() const; // Type specific hashing
815 virtual bool singleton(void) const; // TRUE if type is a singleton
816 virtual bool empty(void) const; // TRUE if type is vacuous
817 // A value is in the set represented by this TypeInt if it satisfies all
818 // the below constraints, see contains(jint)
819 const jint _lo, _hi; // Lower bound, upper bound in the signed domain
820 const juint _ulo, _uhi; // Lower bound, upper bound in the unsigned domain
821 const KnownBits<juint> _bits;
822
823 static const TypeInt* make(jint con);
824 // must always specify w
825 static const TypeInt* make(jint lo, jint hi, int widen);
826 static const Type* make_or_top(const TypeIntPrototype<jint, juint>& t, int widen);
827 static const TypeInt* make(const TypeIntPrototype<jint, juint>& t, int widen) { return make_or_top(t, widen)->is_int(); }
828 static const TypeInt* make(const TypeIntMirror<jint, juint>& t, int widen) {
829 return (new TypeInt(TypeIntPrototype<jint, juint>{{t._lo, t._hi}, {t._ulo, t._uhi}, t._bits}, widen, false))->hashcons()->is_int();
830 }
831
832 // Check for single integer
833 bool is_con() const { return _lo == _hi; }
834 bool is_con(jint i) const { return is_con() && _lo == i; }
835 jint get_con() const { assert(is_con(), ""); return _lo; }
836 // Check if a jint/TypeInt is a subset of this TypeInt (i.e. all elements of the
837 // argument are also elements of this type)
838 bool contains(jint i) const;
839 bool contains(const TypeInt* t) const;
840
841 #ifdef ASSERT
842 // Check whether t is a proper subset (i.e. a subset that is not equal to the superset) of this
843 bool strictly_contains(const TypeInt* t) const;
844 #endif // ASSERT
845
846 virtual bool is_finite() const; // Has a finite value
847
848 virtual const Type* xmeet(const Type* t) const;
849 virtual const Type* xdual() const; // Compute dual right now.
850 virtual const Type* widen(const Type* t, const Type* limit_type) const;
851 virtual const Type* narrow(const Type* t) const;
852
853 virtual jlong hi_as_long() const { return _hi; }
854 virtual jlong lo_as_long() const { return _lo; }
855
856 // Do not kill _widen bits.
857 // Convenience common pre-built types.
858 static const TypeInt* MAX;
859 static const TypeInt* MIN;
860 static const TypeInt* MINUS_1;
861 static const TypeInt* ZERO;
862 static const TypeInt* ONE;
863 static const TypeInt* BOOL;
864 static const TypeInt* CC;
865 static const TypeInt* CC_LT; // [-1] == MINUS_1
866 static const TypeInt* CC_GT; // [1] == ONE
867 static const TypeInt* CC_EQ; // [0] == ZERO
868 static const TypeInt* CC_NE; // [-1, 1]
869 static const TypeInt* CC_LE; // [-1,0]
870 static const TypeInt* CC_GE; // [0,1] == BOOL (!)
871 static const TypeInt* BYTE;
872 static const TypeInt* UBYTE;
873 static const TypeInt* CHAR;
874 static const TypeInt* SHORT;
875 static const TypeInt* NON_ZERO;
876 static const TypeInt* POS;
877 static const TypeInt* POS1;
878 static const TypeInt* INT;
879 static const TypeInt* SYMINT; // symmetric range [-max_jint..max_jint]
880 static const TypeInt* TYPE_DOMAIN; // alias for TypeInt::INT
881
882 static const TypeInt* as_self(const Type* t) { return t->is_int(); }
883 #ifndef PRODUCT
884 virtual void dump2(Dict& d, uint depth, outputStream* st) const;
885 void dump_verbose() const;
886 #endif
887 };
888
889 // Similar to TypeInt
890 class TypeLong : public TypeInteger {
891 private:
892 TypeLong(const TypeIntPrototype<jlong, julong>& t, int w, bool dual);
893 static const Type* make_or_top(const TypeIntPrototype<jlong, julong>& t, int widen, bool dual);
894
895 friend class TypeIntHelper;
896
897 protected:
898 // Do not kill _widen bits.
899 virtual const Type* filter_helper(const Type* kills, bool include_speculative) const;
900 public:
901 typedef jlong NativeType;
902 virtual bool eq( const Type *t ) const;
903 virtual uint hash() const; // Type specific hashing
904 virtual bool singleton(void) const; // TRUE if type is a singleton
905 virtual bool empty(void) const; // TRUE if type is vacuous
906 public:
907 // A value is in the set represented by this TypeLong if it satisfies all
908 // the below constraints, see contains(jlong)
909 const jlong _lo, _hi; // Lower bound, upper bound in the signed domain
910 const julong _ulo, _uhi; // Lower bound, upper bound in the unsigned domain
911 const KnownBits<julong> _bits;
912
913 static const TypeLong* make(jlong con);
914 // must always specify w
915 static const TypeLong* make(jlong lo, jlong hi, int widen);
916 static const Type* make_or_top(const TypeIntPrototype<jlong, julong>& t, int widen);
917 static const TypeLong* make(const TypeIntPrototype<jlong, julong>& t, int widen) { return make_or_top(t, widen)->is_long(); }
918 static const TypeLong* make(const TypeIntMirror<jlong, julong>& t, int widen) {
919 return (new TypeLong(TypeIntPrototype<jlong, julong>{{t._lo, t._hi}, {t._ulo, t._uhi}, t._bits}, widen, false))->hashcons()->is_long();
920 }
921
922 // Check for single integer
923 bool is_con() const { return _lo == _hi; }
924 bool is_con(jlong i) const { return is_con() && _lo == i; }
925 jlong get_con() const { assert(is_con(), "" ); return _lo; }
926 // Check if a jlong/TypeLong is a subset of this TypeLong (i.e. all elements of the
927 // argument are also elements of this type)
928 bool contains(jlong i) const;
929 bool contains(const TypeLong* t) const;
930
931 #ifdef ASSERT
932 // Check whether t is a proper subset (i.e. a subset that is not equal to the superset) of this
933 bool strictly_contains(const TypeLong* t) const;
934 #endif // ASSERT
935
936 // Check for positive 32-bit value.
937 bool is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; }
938
939 virtual bool is_finite() const; // Has a finite value
940
941 virtual jlong hi_as_long() const { return _hi; }
942 virtual jlong lo_as_long() const { return _lo; }
943
944 virtual const Type* xmeet(const Type* t) const;
945 virtual const Type* xdual() const; // Compute dual right now.
946 virtual const Type* widen(const Type* t, const Type* limit_type) const;
947 virtual const Type* narrow(const Type* t) const;
948 // Convenience common pre-built types.
949 static const TypeLong* MAX;
950 static const TypeLong* MIN;
951 static const TypeLong* MINUS_1;
952 static const TypeLong* ZERO;
953 static const TypeLong* ONE;
954 static const TypeLong* NON_ZERO;
955 static const TypeLong* POS;
956 static const TypeLong* NEG;
957 static const TypeLong* LONG;
958 static const TypeLong* INT; // 32-bit subrange [min_jint..max_jint]
959 static const TypeLong* UINT; // 32-bit unsigned [0..max_juint]
960 static const TypeLong* TYPE_DOMAIN; // alias for TypeLong::LONG
961
962 // static convenience methods.
963 static const TypeLong* as_self(const Type* t) { return t->is_long(); }
964
965 #ifndef PRODUCT
966 virtual void dump2(Dict& d, uint, outputStream* st) const;// Specialized per-Type dumping
967 void dump_verbose() const;
968 #endif
969 };
970
971 //------------------------------TypeTuple--------------------------------------
972 // Class of Tuple Types, essentially type collections for function signatures
973 // and class layouts. It happens to also be a fast cache for the HotSpot
974 // signature types.
975 class TypeTuple : public Type {
976 TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
977
978 const uint _cnt; // Count of fields
979 const Type ** const _fields; // Array of field types
980
981 public:
982 virtual bool eq( const Type *t ) const;
983 virtual uint hash() const; // Type specific hashing
984 virtual bool singleton(void) const; // TRUE if type is a singleton
985 virtual bool empty(void) const; // TRUE if type is vacuous
986
987 // Accessors:
988 uint cnt() const { return _cnt; }
989 const Type* field_at(uint i) const {
990 assert(i < _cnt, "oob");
991 return _fields[i];
992 }
993 void set_field_at(uint i, const Type* t) {
994 assert(i < _cnt, "oob");
995 _fields[i] = t;
996 }
997
998 static const TypeTuple *make( uint cnt, const Type **fields );
999 static const TypeTuple *make_range(ciSignature* sig, InterfaceHandling interface_handling = ignore_interfaces, bool ret_vt_fields = false, bool is_call = false);
1000 static const TypeTuple *make_domain(ciMethod* method, InterfaceHandling interface_handling, bool vt_fields_as_args = false);
1001
1002 // Subroutine call type with space allocated for argument types
1003 // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
1004 static const Type **fields( uint arg_cnt );
1005
1006 virtual const Type *xmeet( const Type *t ) const;
1007 virtual const Type *xdual() const; // Compute dual right now.
1008 // Convenience common pre-built types.
1009 static const TypeTuple *IFBOTH;
1010 static const TypeTuple *IFFALSE;
1011 static const TypeTuple *IFTRUE;
1012 static const TypeTuple *IFNEITHER;
1013 static const TypeTuple *LOOPBODY;
1014 static const TypeTuple *MEMBAR;
1015 static const TypeTuple *STORECONDITIONAL;
1016 static const TypeTuple *START_I2C;
1017 static const TypeTuple *INT_PAIR;
1018 static const TypeTuple *LONG_PAIR;
1019 static const TypeTuple *INT_CC_PAIR;
1020 static const TypeTuple *LONG_CC_PAIR;
1021 #ifndef PRODUCT
1022 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
1023 #endif
1024 };
1025
1026 //------------------------------TypeAry----------------------------------------
1027 // Class of Array Types
1028 class TypeAry : public Type {
1029 TypeAry(const Type* elem, const TypeInt* size, bool stable, bool flat, bool not_flat, bool not_null_free, bool atomic) : Type(Array),
1030 _elem(elem), _size(size), _stable(stable), _flat(flat), _not_flat(not_flat), _not_null_free(not_null_free), _atomic(atomic) {}
1031 public:
1032 virtual bool eq( const Type *t ) const;
1033 virtual uint hash() const; // Type specific hashing
1034 virtual bool singleton(void) const; // TRUE if type is a singleton
1035 virtual bool empty(void) const; // TRUE if type is vacuous
1036
1037 private:
1038 const Type *_elem; // Element type of array
1039 const TypeInt *_size; // Elements in array
1040 const bool _stable; // Are elements @Stable?
1041
1042 // Inline type array properties
1043 const bool _flat; // Array is flat
1044 const bool _not_flat; // Array is never flat
1045 const bool _not_null_free; // Array is never null-free
1046 const bool _atomic; // Array is atomic
1047
1048 friend class TypeAryPtr;
1049
1050 public:
1051 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable,
1052 bool flat, bool not_flat, bool not_null_free, bool atomic);
1053
1054 virtual const Type *xmeet( const Type *t ) const;
1055 virtual const Type *xdual() const; // Compute dual right now.
1056 bool ary_must_be_exact() const; // true if arrays of such are never generic
1057 virtual const TypeAry* remove_speculative() const;
1058 virtual const Type* cleanup_speculative() const;
1059 #ifndef PRODUCT
1060 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
1061 #endif
1062 };
1063
1064 //------------------------------TypeVect---------------------------------------
1065 // Basic class of vector (mask) types.
1066 class TypeVect : public Type {
1067 const BasicType _elem_bt; // Vector's element type
1068 const uint _length; // Elements in vector (power of 2)
1069
1070 protected:
1071 TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
1072 _elem_bt(elem_bt), _length(length) {}
1073
1074 public:
1075 BasicType element_basic_type() const { return _elem_bt; }
1076 uint length() const { return _length; }
1077 uint length_in_bytes() const {
1078 return _length * type2aelembytes(element_basic_type());
1079 }
1080
1081 virtual bool eq(const Type* t) const;
1082 virtual uint hash() const; // Type specific hashing
1083 virtual bool singleton(void) const; // TRUE if type is a singleton
1084 virtual bool empty(void) const; // TRUE if type is vacuous
1085
1086 static const TypeVect* make(const BasicType elem_bt, uint length, bool is_mask = false);
1087 static const TypeVect* makemask(const BasicType elem_bt, uint length);
1088
1089 virtual const Type* xmeet( const Type *t) const;
1090 virtual const Type* xdual() const; // Compute dual right now.
1091
1092 static const TypeVect* VECTA;
1093 static const TypeVect* VECTS;
1094 static const TypeVect* VECTD;
1095 static const TypeVect* VECTX;
1096 static const TypeVect* VECTY;
1097 static const TypeVect* VECTZ;
1098 static const TypeVect* VECTMASK;
1099
1100 #ifndef PRODUCT
1101 virtual void dump2(Dict& d, uint, outputStream* st) const; // Specialized per-Type dumping
1102 #endif
1103 };
1104
1105 // TypeVect subclasses representing vectors or vector masks with "BVectMask" or "NVectMask"
1106 // layout (see vectornode.hpp for detailed notes on vector mask representations), mapped
1107 // to vector registers and distinguished by vector register size:
1108 //
1109 // - TypeVectA: Scalable vector type (variable size, e.g., AArch64 SVE, RISC-V RVV)
1110 // - TypeVectS: 32-bit vector type
1111 // - TypeVectD: 64-bit vector type
1112 // - TypeVectX: 128-bit vector type
1113 // - TypeVectY: 256-bit vector type
1114 // - TypeVectZ: 512-bit vector type
1115 class TypeVectA : public TypeVect {
1116 friend class TypeVect;
1117 TypeVectA(BasicType elem_bt, uint length) : TypeVect(VectorA, elem_bt, length) {}
1118 };
1119
1120 class TypeVectS : public TypeVect {
1121 friend class TypeVect;
1122 TypeVectS(BasicType elem_bt, uint length) : TypeVect(VectorS, elem_bt, length) {}
1123 };
1124
1125 class TypeVectD : public TypeVect {
1126 friend class TypeVect;
1127 TypeVectD(BasicType elem_bt, uint length) : TypeVect(VectorD, elem_bt, length) {}
1128 };
1129
1130 class TypeVectX : public TypeVect {
1131 friend class TypeVect;
1132 TypeVectX(BasicType elem_bt, uint length) : TypeVect(VectorX, elem_bt, length) {}
1133 };
1134
1135 class TypeVectY : public TypeVect {
1136 friend class TypeVect;
1137 TypeVectY(BasicType elem_bt, uint length) : TypeVect(VectorY, elem_bt, length) {}
1138 };
1139
1140 class TypeVectZ : public TypeVect {
1141 friend class TypeVect;
1142 TypeVectZ(BasicType elem_bt, uint length) : TypeVect(VectorZ, elem_bt, length) {}
1143 };
1144
1145 // Class of TypePVectMask, representing vector masks with "PVectMask" layout (see
1146 // vectornode.hpp for detailed notes on vector mask representations), mapped to
1147 // dedicated hardware predicate/mask registers.
1148 class TypePVectMask : public TypeVect {
1149 public:
1150 friend class TypeVect;
1151 TypePVectMask(BasicType elem_bt, uint length) : TypeVect(VectorMask, elem_bt, length) {}
1152 static const TypePVectMask* make(const BasicType elem_bt, uint length);
1153 };
1154
1155 // Set of implemented interfaces. Referenced from TypeOopPtr and TypeKlassPtr.
1156 class TypeInterfaces : public Type {
1157 private:
1158 GrowableArrayFromArray<ciInstanceKlass*> _interfaces;
1159 uint _hash;
1160 ciInstanceKlass* _exact_klass;
1161 DEBUG_ONLY(bool _initialized;)
1162
1163 void initialize();
1164
1165 void verify() const NOT_DEBUG_RETURN;
1166 void compute_hash();
1167 void compute_exact_klass();
1168
1169 TypeInterfaces(ciInstanceKlass** interfaces_base, int nb_interfaces);
1170
1171 NONCOPYABLE(TypeInterfaces);
1172 public:
1173 static const TypeInterfaces* make(GrowableArray<ciInstanceKlass*>* interfaces = nullptr);
1174 bool eq(const Type* other) const;
1175 bool eq(ciInstanceKlass* k) const;
1176 bool is_subset(ciInstanceKlass* k) const;
1177 uint hash() const;
1178 const Type *xdual() const;
1179 void dump(outputStream* st) const;
1180 const TypeInterfaces* union_with(const TypeInterfaces* other) const;
1181 const TypeInterfaces* intersection_with(const TypeInterfaces* other) const;
1182 bool contains(const TypeInterfaces* other) const {
1183 return intersection_with(other)->eq(other);
1184 }
1185 bool empty() const { return _interfaces.length() == 0; }
1186
1187 ciInstanceKlass* exact_klass() const;
1188 void verify_is_loaded() const NOT_DEBUG_RETURN;
1189
1190 static int compare(ciInstanceKlass* const& k1, ciInstanceKlass* const& k2);
1191 static int compare(ciInstanceKlass** k1, ciInstanceKlass** k2);
1192
1193 const Type* xmeet(const Type* t) const;
1194
1195 bool singleton(void) const;
1196 bool has_non_array_interface() const;
1197 };
1198
1199 //------------------------------TypePtr----------------------------------------
1200 // Class of machine Pointer Types: raw data, instances or arrays.
1201 // If the _base enum is AnyPtr, then this refers to all of the above.
1202 // Otherwise the _base will indicate which subset of pointers is affected,
1203 // and the class will be inherited from.
1204 class TypePtr : public Type {
1205 friend class TypeNarrowPtr;
1206 friend class Type;
1207 protected:
1208 static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
1209
1210 public:
1211 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
1212
1213 // Only applies to TypeInstPtr and TypeInstKlassPtr. Since the common super class is TypePtr, it is defined here.
1214 //
1215 // FlatInArray defines the following Boolean Lattice structure
1216 //
1217 // TopFlat
1218 // / \
1219 // Flat NotFlat
1220 // \ /
1221 // MaybeFlat
1222 //
1223 // with meet (see TypePtr::meet_flat_in_array()) and join (implemented over dual, see TypePtr::flat_in_array_dual)
1224 enum FlatInArray {
1225 TopFlat, // Dedicated top element and dual of MaybeFlat. Result when joining Flat and NotFlat.
1226 Flat, // An instance is always flat in an array.
1227 NotFlat, // An instance is never flat in an array.
1228 MaybeFlat, // We don't know whether an instance is flat in an array.
1229 Uninitialized // Used when the flat in array property was not computed, yet - should never actually end up in a type.
1230 };
1231 protected:
1232 TypePtr(TYPES t, PTR ptr, Offset offset,
1233 relocInfo::relocType reloc,
1234 const TypePtr* speculative = nullptr,
1235 int inline_depth = InlineDepthBottom) :
1236 Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
1237 _ptr(ptr), _reloc(reloc) {}
1238 static const PTR ptr_meet[lastPTR][lastPTR];
1239 static const PTR ptr_dual[lastPTR];
1240 static const char * const ptr_msg[lastPTR];
1241
1242 static const FlatInArray flat_in_array_dual[Uninitialized];
1243 static const char* const flat_in_array_msg[Uninitialized];
1244
1245 enum {
1246 InlineDepthBottom = INT_MAX,
1247 InlineDepthTop = -InlineDepthBottom
1248 };
1249
1250 // Extra type information profiling gave us. We propagate it the
1251 // same way the rest of the type info is propagated. If we want to
1252 // use it, then we have to emit a guard: this part of the type is
1253 // not something we know but something we speculate about the type.
1254 const TypePtr* _speculative;
1255 // For speculative types, we record at what inlining depth the
1256 // profiling point that provided the data is. We want to favor
1257 // profile data coming from outer scopes which are likely better for
1258 // the current compilation.
1259 int _inline_depth;
1260
1261 // utility methods to work on the speculative part of the type
1262 const TypePtr* dual_speculative() const;
1263 const TypePtr* xmeet_speculative(const TypePtr* other) const;
1264 bool eq_speculative(const TypePtr* other) const;
1265 int hash_speculative() const;
1266 const TypePtr* add_offset_speculative(intptr_t offset) const;
1267 const TypePtr* with_offset_speculative(intptr_t offset) const;
1268
1269 // utility methods to work on the inline depth of the type
1270 int dual_inline_depth() const;
1271 int meet_inline_depth(int depth) const;
1272
1273 #ifndef PRODUCT
1274 void dump_speculative(outputStream* st) const;
1275 void dump_inline_depth(outputStream* st) const;
1276 void dump_offset(outputStream* st) const;
1277 #endif
1278
1279 // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1280 // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1281 // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1282 // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1283 // encountered so the right logic specific to klasses or oops can be executed.,
1284 enum MeetResult {
1285 QUICK,
1286 UNLOADED,
1287 SUBTYPE,
1288 NOT_SUBTYPE,
1289 LCA
1290 };
1291 template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1292 const T* other_type, ciKlass*& res_klass, bool& res_xk);
1293 protected:
1294 static FlatInArray meet_flat_in_array(FlatInArray left, FlatInArray other);
1295
1296 template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1297 ciKlass*& res_klass, bool& res_xk, bool &res_flat, bool &res_not_flat, bool &res_not_null_free, bool &res_atomic);
1298
1299 template <class T1, class T2> static bool is_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1300 template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1301 template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1302 template <class T1, class T2> static bool is_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1303 template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1304 template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1305 template <class T1, class T2> static bool is_meet_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1306 template <class T1, class T2> static bool is_meet_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1307 public:
1308 const Offset _offset; // Offset into oop, with TOP & BOT
1309 const PTR _ptr; // Pointer equivalence class
1310 const relocInfo::relocType _reloc;
1311
1312 int offset() const { return _offset.get(); }
1313 PTR ptr() const { return _ptr; }
1314 relocInfo::relocType reloc() const { return _reloc; }
1315
1316 static const TypePtr* make(TYPES t, PTR ptr, Offset offset,
1317 const TypePtr* speculative = nullptr,
1318 int inline_depth = InlineDepthBottom,
1319 relocInfo::relocType reloc = relocInfo::none);
1320
1321 // Return a 'ptr' version of this type
1322 virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1323
1324 virtual intptr_t get_con() const;
1325
1326 Type::Offset xadd_offset(intptr_t offset) const;
1327 virtual const TypePtr* add_offset(intptr_t offset) const;
1328 virtual const TypePtr* with_offset(intptr_t offset) const;
1329 virtual int flat_offset() const { return offset(); }
1330 virtual bool eq(const Type *t) const;
1331 virtual uint hash() const; // Type specific hashing
1332
1333 virtual bool singleton(void) const; // TRUE if type is a singleton
1334 virtual bool empty(void) const; // TRUE if type is vacuous
1335 virtual const Type *xmeet( const Type *t ) const;
1336 virtual const Type *xmeet_helper( const Type *t ) const;
1337 Offset meet_offset(int offset) const;
1338 Offset dual_offset() const;
1339 virtual const Type *xdual() const; // Compute dual right now.
1340
1341 // meet, dual and join over pointer equivalence sets
1342 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1343 PTR dual_ptr() const { return ptr_dual[ptr()]; }
1344
1345 // This is textually confusing unless one recalls that
1346 // join(t) == dual()->meet(t->dual())->dual().
1347 PTR join_ptr( const PTR in_ptr ) const {
1348 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1349 }
1350
1351 // Speculative type helper methods.
1352 virtual const TypePtr* speculative() const { return _speculative; }
1353 int inline_depth() const { return _inline_depth; }
1354 virtual ciKlass* speculative_type() const;
1355 virtual ciKlass* speculative_type_not_null() const;
1356 virtual bool speculative_maybe_null() const;
1357 virtual bool speculative_always_null() const;
1358 virtual const TypePtr* remove_speculative() const;
1359 virtual const Type* cleanup_speculative() const;
1360 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1361 virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1362 virtual const TypePtr* with_inline_depth(int depth) const;
1363
1364 virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1365
1366 NOT_PRODUCT(static void dump_flat_in_array(FlatInArray flat_in_array, outputStream* st);)
1367
1368 static FlatInArray compute_flat_in_array(ciInstanceKlass* instance_klass, bool is_exact);
1369
1370 static FlatInArray compute_flat_in_array_if_unknown(ciInstanceKlass* instance_klass, bool is_exact,
1371 FlatInArray old_flat_in_array);
1372
1373 virtual bool can_be_inline_type() const { return false; }
1374 virtual bool is_flat_in_array() const { return flat_in_array() == Flat; }
1375 virtual bool is_not_flat_in_array() const { return flat_in_array() == NotFlat; }
1376 virtual FlatInArray flat_in_array() const { return NotFlat; }
1377 virtual bool is_flat() const { return false; }
1378 virtual bool is_not_flat() const { return false; }
1379 virtual bool is_null_free() const { return false; }
1380 virtual bool is_not_null_free() const { return false; }
1381 virtual bool is_atomic() const { return false; }
1382
1383 // Tests for relation to centerline of type lattice:
1384 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1385 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1386 // Convenience common pre-built types.
1387 static const TypePtr *NULL_PTR;
1388 static const TypePtr *NOTNULL;
1389 static const TypePtr *BOTTOM;
1390 #ifndef PRODUCT
1391 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1392 #endif
1393 };
1394
1395 //------------------------------TypeRawPtr-------------------------------------
1396 // Class of raw pointers, pointers to things other than Oops. Examples
1397 // include the stack pointer, top of heap, card-marking area, handles, etc.
1398 class TypeRawPtr : public TypePtr {
1399 protected:
1400 TypeRawPtr(PTR ptr, address bits, relocInfo::relocType reloc) : TypePtr(RawPtr, ptr, Offset(0), reloc), _bits(bits){}
1401 public:
1402 virtual bool eq( const Type *t ) const;
1403 virtual uint hash() const; // Type specific hashing
1404
1405 const address _bits; // Constant value, if applicable
1406
1407 static const TypeRawPtr* make(PTR ptr);
1408 static const TypeRawPtr* make(address bits, relocInfo::relocType reloc = relocInfo::external_word_type);
1409
1410 // Return a 'ptr' version of this type
1411 virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1412
1413 virtual intptr_t get_con() const;
1414
1415 virtual const TypePtr* add_offset(intptr_t offset) const;
1416 virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1417
1418 virtual const Type *xmeet( const Type *t ) const;
1419 virtual const Type *xdual() const; // Compute dual right now.
1420 // Convenience common pre-built types.
1421 static const TypeRawPtr *BOTTOM;
1422 static const TypeRawPtr *NOTNULL;
1423 #ifndef PRODUCT
1424 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1425 #endif
1426 };
1427
1428 //------------------------------TypeOopPtr-------------------------------------
1429 // Some kind of oop (Java pointer), either instance or array.
1430 class TypeOopPtr : public TypePtr {
1431 friend class TypeAry;
1432 friend class TypePtr;
1433 friend class TypeInstPtr;
1434 friend class TypeAryPtr;
1435 protected:
1436 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset, Offset field_offset, int instance_id,
1437 const TypePtr* speculative, int inline_depth);
1438 public:
1439 virtual bool eq( const Type *t ) const;
1440 virtual uint hash() const; // Type specific hashing
1441 virtual bool singleton(void) const; // TRUE if type is a singleton
1442 enum {
1443 InstanceTop = -1, // undefined instance
1444 InstanceBot = 0 // any possible instance
1445 };
1446 protected:
1447
1448 // Oop is null, unless this is a constant oop.
1449 ciObject* _const_oop; // Constant oop
1450 // If _klass is null, then so is _sig. This is an unloaded klass.
1451 ciKlass* _klass; // Klass object
1452
1453 const TypeInterfaces* _interfaces;
1454
1455 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
1456 bool _klass_is_exact;
1457 bool _is_ptr_to_narrowoop;
1458 bool _is_ptr_to_narrowklass;
1459 bool _is_ptr_to_boxed_value;
1460 bool _is_ptr_to_strict_final_field;
1461
1462 // If not InstanceTop or InstanceBot, indicates that this is
1463 // a particular instance of this type which is distinct.
1464 // This is the node index of the allocation node creating this instance.
1465 int _instance_id;
1466
1467 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1468
1469 int dual_instance_id() const;
1470 int meet_instance_id(int uid) const;
1471
1472 const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1473
1474 // Do not allow interface-vs.-noninterface joins to collapse to top.
1475 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1476
1477 virtual ciKlass* exact_klass_helper() const { return nullptr; }
1478 virtual ciKlass* klass() const { return _klass; }
1479
1480 #ifndef PRODUCT
1481 void dump_instance_id(outputStream* st) const;
1482 #endif // PRODUCT
1483
1484 public:
1485
1486 bool is_java_subtype_of(const TypeOopPtr* other) const {
1487 return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1488 }
1489
1490 bool is_same_java_type_as(const TypePtr* other) const {
1491 return is_same_java_type_as_helper(other->is_oopptr());
1492 }
1493
1494 virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1495 ShouldNotReachHere(); return false;
1496 }
1497
1498 bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1499 return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1500 }
1501 virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1502 virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1503
1504
1505 // Creates a type given a klass. Correctly handles multi-dimensional arrays
1506 // Respects UseUniqueSubclasses.
1507 // If the klass is final, the resulting type will be exact.
1508 static const TypeOopPtr* make_from_klass(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1509 return make_from_klass_common(klass, true, false, interface_handling);
1510 }
1511 // Same as before, but will produce an exact type, even if
1512 // the klass is not final, as long as it has exactly one implementation.
1513 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1514 return make_from_klass_common(klass, true, true, interface_handling);
1515 }
1516 // Same as before, but does not respects UseUniqueSubclasses.
1517 // Use this only for creating array element types.
1518 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1519 return make_from_klass_common(klass, false, false, interface_handling);
1520 }
1521 // Creates a singleton type given an object.
1522 // If the object cannot be rendered as a constant,
1523 // may return a non-singleton type.
1524 // If require_constant, produce a null if a singleton is not possible.
1525 static const TypeOopPtr* make_from_constant(ciObject* o,
1526 bool require_constant = false);
1527
1528 // Make a generic (unclassed) pointer to an oop.
1529 static const TypeOopPtr* make(PTR ptr, Offset offset, int instance_id,
1530 const TypePtr* speculative = nullptr,
1531 int inline_depth = InlineDepthBottom);
1532
1533 ciObject* const_oop() const { return _const_oop; }
1534 // Exact klass, possibly an interface or an array of interface
1535 ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k; }
1536 ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1537
1538 virtual bool is_loaded() const { return klass()->is_loaded(); }
1539 virtual bool klass_is_exact() const { return _klass_is_exact; }
1540
1541 // Returns true if this pointer points at memory which contains a
1542 // compressed oop references.
1543 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1544 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1545 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
1546 bool is_ptr_to_strict_final_field() const { return _is_ptr_to_strict_final_field; }
1547 bool is_known_instance() const { return _instance_id > 0; }
1548 int instance_id() const { return _instance_id; }
1549 bool is_known_instance_field() const { return is_known_instance() && _offset.get() >= 0; }
1550
1551 virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(_klass_is_exact)); }
1552 virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1553
1554 virtual intptr_t get_con() const;
1555
1556 virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1557
1558 virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1559
1560 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1561
1562 // corresponding pointer to klass, for a given instance
1563 virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1564
1565 virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1566 virtual const TypePtr* add_offset(intptr_t offset) const;
1567
1568 // Speculative type helper methods.
1569 virtual const TypeOopPtr* remove_speculative() const;
1570 virtual const Type* cleanup_speculative() const;
1571 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1572 virtual const TypePtr* with_inline_depth(int depth) const;
1573
1574 virtual const TypePtr* with_instance_id(int instance_id) const;
1575
1576 virtual const Type *xdual() const; // Compute dual right now.
1577 // the core of the computation of the meet for TypeOopPtr and for its subclasses
1578 virtual const Type *xmeet_helper(const Type *t) const;
1579
1580 // Convenience common pre-built type.
1581 static const TypeOopPtr *BOTTOM;
1582 #ifndef PRODUCT
1583 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1584 #endif
1585 private:
1586 virtual bool is_meet_subtype_of(const TypePtr* other) const {
1587 return is_meet_subtype_of_helper(other->is_oopptr(), klass_is_exact(), other->is_oopptr()->klass_is_exact());
1588 }
1589
1590 virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const {
1591 ShouldNotReachHere(); return false;
1592 }
1593
1594 virtual const TypeInterfaces* interfaces() const {
1595 return _interfaces;
1596 };
1597
1598 const TypeOopPtr* is_reference_type(const Type* other) const {
1599 return other->isa_oopptr();
1600 }
1601
1602 const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1603 return other->isa_aryptr();
1604 }
1605
1606 const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1607 return other->isa_instptr();
1608 }
1609 };
1610
1611 //------------------------------TypeInstPtr------------------------------------
1612 // Class of Java object pointers, pointing either to non-array Java instances
1613 // or to a Klass* (including array klasses).
1614 class TypeInstPtr : public TypeOopPtr {
1615 // Can this instance be in a flat array?
1616 FlatInArray _flat_in_array;
1617
1618 TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1619 FlatInArray flat_in_array, int instance_id, const TypePtr* speculative,
1620 int inline_depth);
1621 virtual bool eq( const Type *t ) const;
1622 virtual uint hash() const; // Type specific hashing
1623 ciKlass* exact_klass_helper() const;
1624
1625 public:
1626
1627 // Instance klass, ignoring any interface
1628 ciInstanceKlass* instance_klass() const {
1629 assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1630 return klass()->as_instance_klass();
1631 }
1632
1633 bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1634 bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1635 bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1636
1637 // Make a pointer to a constant oop.
1638 static const TypeInstPtr *make(ciObject* o) {
1639 ciKlass* k = o->klass();
1640 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1641 return make(TypePtr::Constant, k, interfaces, true, o, Offset(0));
1642 }
1643 // Make a pointer to a constant oop with offset.
1644 static const TypeInstPtr *make(ciObject* o, Offset offset) {
1645 ciKlass* k = o->klass();
1646 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1647 return make(TypePtr::Constant, k, interfaces, true, o, offset);
1648 }
1649
1650 // Make a pointer to some value of type klass.
1651 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1652 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1653 return make(ptr, klass, interfaces, false, nullptr, Offset(0));
1654 }
1655
1656 // Make a pointer to some non-polymorphic value of exactly type klass.
1657 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1658 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1659 return make(ptr, klass, interfaces, true, nullptr, Offset(0));
1660 }
1661
1662 // Make a pointer to some value of type klass with offset.
1663 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, Offset offset) {
1664 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1665 return make(ptr, klass, interfaces, false, nullptr, offset);
1666 }
1667
1668 // Make a pointer to an oop.
1669 static const TypeInstPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1670 FlatInArray flat_in_array = Uninitialized,
1671 int instance_id = InstanceBot,
1672 const TypePtr* speculative = nullptr,
1673 int inline_depth = InlineDepthBottom);
1674
1675 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, int instance_id = InstanceBot,
1676 FlatInArray flat_in_array = Uninitialized) {
1677 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1678 return make(ptr, k, interfaces, xk, o, offset, flat_in_array, instance_id);
1679 }
1680
1681 // If this is a java.lang.Class constant, return the type for it or null.
1682 // Pass to Type::get_const_type to turn it to a type, which will usually
1683 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1684 ciType* java_mirror_type() const;
1685
1686 virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1687
1688 virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1689
1690 virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1691
1692 virtual bool empty() const;
1693 virtual const TypePtr* add_offset(intptr_t offset) const;
1694 virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1695
1696 // Speculative type helper methods.
1697 virtual const TypeInstPtr* remove_speculative() const;
1698 const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1699 virtual const TypePtr* with_inline_depth(int depth) const;
1700 virtual const TypePtr* with_instance_id(int instance_id) const;
1701
1702 virtual const TypeInstPtr* cast_to_flat_in_array() const;
1703 virtual const TypeInstPtr* cast_to_maybe_flat_in_array() const;
1704 virtual FlatInArray flat_in_array() const { return _flat_in_array; }
1705
1706 FlatInArray dual_flat_in_array() const {
1707 return flat_in_array_dual[_flat_in_array];
1708 }
1709
1710 // the core of the computation of the meet of 2 types
1711 virtual const Type *xmeet_helper(const Type *t) const;
1712 virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1713 virtual const Type *xdual() const; // Compute dual right now.
1714
1715 const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1716
1717 virtual bool can_be_inline_array() const;
1718
1719 // Convenience common pre-built types.
1720 static const TypeInstPtr *NOTNULL;
1721 static const TypeInstPtr *BOTTOM;
1722 static const TypeInstPtr *MIRROR;
1723 static const TypeInstPtr *MARK;
1724 static const TypeInstPtr *KLASS;
1725 #ifndef PRODUCT
1726 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1727 #endif
1728
1729 private:
1730 virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1731
1732 virtual bool is_meet_same_type_as(const TypePtr* other) const {
1733 return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1734 }
1735
1736 };
1737
1738 //------------------------------TypeAryPtr-------------------------------------
1739 // Class of Java array pointers
1740 class TypeAryPtr : public TypeOopPtr {
1741 friend class Type;
1742 friend class TypePtr;
1743 friend class TypeInstPtr;
1744 friend class TypeInterfaces;
1745
1746 TypeAryPtr(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1747 Offset offset, Offset field_offset, int instance_id, bool is_autobox_cache,
1748 const TypePtr* speculative, int inline_depth)
1749 : TypeOopPtr(AryPtr, ptr, k, _array_interfaces, xk, o, offset, field_offset, instance_id, speculative, inline_depth),
1750 _ary(ary),
1751 _is_autobox_cache(is_autobox_cache),
1752 _field_offset(field_offset)
1753 {
1754 int dummy;
1755 bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1756
1757 if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1758 _offset.get() != 0 && _offset.get() != arrayOopDesc::length_offset_in_bytes() &&
1759 _offset.get() != arrayOopDesc::klass_offset_in_bytes()) {
1760 _is_ptr_to_narrowoop = true;
1761 }
1762
1763 }
1764 virtual bool eq( const Type *t ) const;
1765 virtual uint hash() const; // Type specific hashing
1766 const TypeAry *_ary; // Array we point into
1767 const bool _is_autobox_cache;
1768 // For flat inline type arrays, each field of the inline type in
1769 // the array has its own memory slice so we need to keep track of
1770 // which field is accessed
1771 const Offset _field_offset;
1772 Offset meet_field_offset(const Type::Offset offset) const;
1773 Offset dual_field_offset() const;
1774
1775 ciKlass* compute_klass() const;
1776
1777 // A pointer to delay allocation to Type::Initialize_shared()
1778
1779 static const TypeInterfaces* _array_interfaces;
1780 ciKlass* exact_klass_helper() const;
1781 // Only guaranteed non null for array of basic types
1782 ciKlass* klass() const;
1783
1784 public:
1785
1786 bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1787 bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1788 bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1789
1790 // returns base element type, an instance klass (and not interface) for object arrays
1791 const Type* base_element_type(int& dims) const;
1792
1793 // Accessors
1794 bool is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1795
1796 const TypeAry* ary() const { return _ary; }
1797 const Type* elem() const { return _ary->_elem; }
1798 const TypeInt* size() const { return _ary->_size; }
1799 bool is_stable() const { return _ary->_stable; }
1800
1801 // Inline type array properties
1802 bool is_flat() const { return _ary->_flat; }
1803 bool is_not_flat() const { return _ary->_not_flat; }
1804 bool is_null_free() const { return _ary->_elem->make_ptr() != nullptr && (_ary->_elem->make_ptr()->ptr() == NotNull || _ary->_elem->make_ptr()->ptr() == AnyNull); }
1805 bool is_not_null_free() const { return _ary->_not_null_free; }
1806 bool is_atomic() const { return _ary->_atomic; }
1807
1808 bool is_autobox_cache() const { return _is_autobox_cache; }
1809
1810 static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1811 Offset field_offset = Offset::bottom,
1812 int instance_id = InstanceBot,
1813 const TypePtr* speculative = nullptr,
1814 int inline_depth = InlineDepthBottom);
1815 // Constant pointer to array
1816 static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1817 Offset field_offset = Offset::bottom,
1818 int instance_id = InstanceBot,
1819 const TypePtr* speculative = nullptr,
1820 int inline_depth = InlineDepthBottom,
1821 bool is_autobox_cache = false);
1822
1823 // Return a 'ptr' version of this type
1824 virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1825
1826 virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1827
1828 virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1829
1830 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1831 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1832
1833 virtual bool empty(void) const; // TRUE if type is vacuous
1834 virtual const TypePtr *add_offset( intptr_t offset ) const;
1835 virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1836 const TypeAryPtr* with_ary(const TypeAry* ary) const;
1837
1838 // Speculative type helper methods.
1839 virtual const TypeAryPtr* remove_speculative() const;
1840 virtual const Type* cleanup_speculative() const;
1841 virtual const TypePtr* with_inline_depth(int depth) const;
1842 virtual const TypePtr* with_instance_id(int instance_id) const;
1843
1844 // the core of the computation of the meet of 2 types
1845 virtual const Type *xmeet_helper(const Type *t) const;
1846 virtual const Type *xdual() const; // Compute dual right now.
1847
1848 // Inline type array properties
1849 const TypeAryPtr* cast_to_flat(bool flat) const;
1850 const TypeAryPtr* cast_to_not_flat(bool not_flat = true) const;
1851 const TypeAryPtr* cast_to_null_free(bool null_free) const;
1852 const TypeAryPtr* cast_to_not_null_free(bool not_null_free = true) const;
1853 const TypeAryPtr* update_properties(const TypeAryPtr* new_type) const;
1854 jint flat_layout_helper() const;
1855 int flat_elem_size() const;
1856 int flat_log_elem_size() const;
1857
1858 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1859 int stable_dimension() const;
1860
1861 const TypeAryPtr* cast_to_autobox_cache() const;
1862
1863 static jint max_array_length(BasicType etype);
1864
1865 int flat_offset() const;
1866 const Offset field_offset() const { return _field_offset; }
1867 const TypeAryPtr* with_field_offset(int offset) const;
1868 const TypePtr* add_field_offset_and_offset(intptr_t offset) const;
1869
1870 virtual bool can_be_inline_type() const { return false; }
1871 virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1872
1873 virtual bool can_be_inline_array() const;
1874
1875 // Convenience common pre-built types.
1876 static const TypeAryPtr* BOTTOM;
1877 static const TypeAryPtr *RANGE;
1878 static const TypeAryPtr *OOPS;
1879 static const TypeAryPtr *NARROWOOPS;
1880 static const TypeAryPtr *BYTES;
1881 static const TypeAryPtr *SHORTS;
1882 static const TypeAryPtr *CHARS;
1883 static const TypeAryPtr *INTS;
1884 static const TypeAryPtr *LONGS;
1885 static const TypeAryPtr *FLOATS;
1886 static const TypeAryPtr *DOUBLES;
1887 static const TypeAryPtr *INLINES;
1888 // selects one of the above:
1889 static const TypeAryPtr *get_array_body_type(BasicType elem) {
1890 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1891 return _array_body_type[elem];
1892 }
1893 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1894 // sharpen the type of an int which is used as an array size
1895 #ifndef PRODUCT
1896 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1897 #endif
1898 private:
1899 virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1900 };
1901
1902 //------------------------------TypeMetadataPtr-------------------------------------
1903 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1904 class TypeMetadataPtr : public TypePtr {
1905 protected:
1906 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, Offset offset);
1907 // Do not allow interface-vs.-noninterface joins to collapse to top.
1908 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1909 public:
1910 virtual bool eq( const Type *t ) const;
1911 virtual uint hash() const; // Type specific hashing
1912 virtual bool singleton(void) const; // TRUE if type is a singleton
1913
1914 private:
1915 ciMetadata* _metadata;
1916
1917 public:
1918 static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, Offset offset);
1919
1920 static const TypeMetadataPtr* make(ciMethod* m);
1921 static const TypeMetadataPtr* make(ciMethodData* m);
1922
1923 ciMetadata* metadata() const { return _metadata; }
1924
1925 virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1926
1927 virtual const TypePtr *add_offset( intptr_t offset ) const;
1928
1929 virtual const Type *xmeet( const Type *t ) const;
1930 virtual const Type *xdual() const; // Compute dual right now.
1931
1932 virtual intptr_t get_con() const;
1933
1934 // Convenience common pre-built types.
1935 static const TypeMetadataPtr *BOTTOM;
1936
1937 #ifndef PRODUCT
1938 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1939 #endif
1940 };
1941
1942 //------------------------------TypeKlassPtr-----------------------------------
1943 // Class of Java Klass pointers
1944 class TypeKlassPtr : public TypePtr {
1945 friend class TypeInstKlassPtr;
1946 friend class TypeAryKlassPtr;
1947 friend class TypePtr;
1948 protected:
1949 TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset);
1950
1951 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1952
1953 public:
1954 virtual bool eq( const Type *t ) const;
1955 virtual uint hash() const;
1956 virtual bool singleton(void) const; // TRUE if type is a singleton
1957
1958 protected:
1959
1960 ciKlass* _klass;
1961 const TypeInterfaces* _interfaces;
1962 const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1963 virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1964 virtual ciKlass* exact_klass_helper() const;
1965 virtual ciKlass* klass() const { return _klass; }
1966
1967 public:
1968
1969 bool is_java_subtype_of(const TypeKlassPtr* other) const {
1970 return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1971 }
1972 bool is_same_java_type_as(const TypePtr* other) const {
1973 return is_same_java_type_as_helper(other->is_klassptr());
1974 }
1975
1976 bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1977 return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1978 }
1979 virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1980 virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1981 virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1982
1983 // Exact klass, possibly an interface or an array of interface
1984 ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k; }
1985 virtual bool klass_is_exact() const { return _ptr == Constant; }
1986
1987 static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1988
1989 virtual bool is_loaded() const { return _klass->is_loaded(); }
1990
1991 virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1992
1993 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1994
1995 // corresponding pointer to instance, for a given class
1996 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1997
1998 virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1999 virtual const Type *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
2000 virtual const Type *xdual() const { ShouldNotReachHere(); return nullptr; }
2001
2002 virtual intptr_t get_con() const;
2003
2004 virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
2005
2006 virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
2007
2008 virtual const TypeKlassPtr* try_improve() const { return this; }
2009
2010 private:
2011 virtual bool is_meet_subtype_of(const TypePtr* other) const {
2012 return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
2013 }
2014
2015 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
2016 ShouldNotReachHere(); return false;
2017 }
2018
2019 virtual const TypeInterfaces* interfaces() const {
2020 return _interfaces;
2021 };
2022
2023 const TypeKlassPtr* is_reference_type(const Type* other) const {
2024 return other->isa_klassptr();
2025 }
2026
2027 const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
2028 return other->isa_aryklassptr();
2029 }
2030
2031 const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
2032 return other->isa_instklassptr();
2033 }
2034 };
2035
2036 // Instance klass pointer, mirrors TypeInstPtr
2037 class TypeInstKlassPtr : public TypeKlassPtr {
2038 // Can an instance of this class be in a flat array?
2039 const FlatInArray _flat_in_array;
2040
2041 TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset, FlatInArray flat_in_array)
2042 : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset), _flat_in_array(flat_in_array) {
2043 assert(flat_in_array != Uninitialized, "must be set now");
2044 assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
2045 }
2046
2047 virtual bool must_be_exact() const;
2048
2049 public:
2050 // Instance klass ignoring any interface
2051 ciInstanceKlass* instance_klass() const {
2052 assert(!klass()->is_interface(), "");
2053 return klass()->as_instance_klass();
2054 }
2055
2056 bool might_be_an_array() const;
2057
2058 bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
2059 bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2060 bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2061
2062 virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(klass_is_exact())); }
2063
2064 static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
2065 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
2066 return make(TypePtr::Constant, k, interfaces, Offset(0));
2067 }
2068
2069 static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, Offset offset,
2070 FlatInArray flat_in_array = Uninitialized);
2071
2072 static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, FlatInArray flat_in_array = Uninitialized) {
2073 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
2074 return make(ptr, k, interfaces, offset, flat_in_array);
2075 }
2076
2077 virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
2078
2079 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
2080
2081 // corresponding pointer to instance, for a given class
2082 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
2083 virtual uint hash() const;
2084 virtual bool eq(const Type *t) const;
2085
2086
2087 virtual bool empty() const;
2088 virtual const TypePtr *add_offset( intptr_t offset ) const;
2089 virtual const Type *xmeet( const Type *t ) const;
2090 virtual const Type *xdual() const;
2091 virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
2092
2093 virtual const TypeKlassPtr* try_improve() const;
2094
2095 virtual FlatInArray flat_in_array() const { return _flat_in_array; }
2096
2097 FlatInArray dual_flat_in_array() const {
2098 return flat_in_array_dual[_flat_in_array];
2099 }
2100
2101 virtual bool can_be_inline_array() const;
2102
2103 // Convenience common pre-built types.
2104 static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
2105 static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
2106
2107 #ifndef PRODUCT
2108 virtual void dump2(Dict& d, uint depth, outputStream* st) const;
2109 #endif // PRODUCT
2110
2111 private:
2112 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
2113 };
2114
2115 // Array klass pointer, mirrors TypeAryPtr
2116 class TypeAryKlassPtr : public TypeKlassPtr {
2117 friend class TypeInstKlassPtr;
2118 friend class Type;
2119 friend class TypePtr;
2120
2121 const Type *_elem;
2122 const bool _not_flat; // Array is never flat
2123 const bool _not_null_free; // Array is never null-free
2124 const bool _flat;
2125 const bool _null_free;
2126 const bool _atomic;
2127 const bool _refined_type;
2128
2129 static const TypeInterfaces* _array_interfaces;
2130 TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, Offset offset, bool not_flat, bool not_null_free, bool flat, bool null_free, bool atomic, bool refined_type)
2131 : TypeKlassPtr(AryKlassPtr, ptr, klass, _array_interfaces, offset), _elem(elem), _not_flat(not_flat), _not_null_free(not_null_free), _flat(flat), _null_free(null_free), _atomic(atomic), _refined_type(refined_type) {
2132 assert(klass == nullptr || klass->is_type_array_klass() || klass->is_flat_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
2133 }
2134
2135 virtual ciKlass* exact_klass_helper() const;
2136 // Only guaranteed non null for array of basic types
2137 virtual ciKlass* klass() const;
2138
2139 virtual bool must_be_exact() const;
2140
2141 bool dual_flat() const {
2142 return _flat;
2143 }
2144
2145 bool meet_flat(bool other) const {
2146 return _flat && other;
2147 }
2148
2149 bool dual_null_free() const {
2150 return _null_free;
2151 }
2152
2153 bool meet_null_free(bool other) const {
2154 return _null_free && other;
2155 }
2156
2157 bool dual_atomic() const {
2158 return _atomic;
2159 }
2160
2161 bool meet_atomic(bool other) const {
2162 return _atomic && other;
2163 }
2164
2165 public:
2166
2167 // returns base element type, an instance klass (and not interface) for object arrays
2168 const Type* base_element_type(int& dims) const;
2169
2170 static const TypeAryKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, InterfaceHandling interface_handling, bool not_flat, bool not_null_free, bool flat, bool null_free, bool atomic, bool refined_type);
2171
2172 bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
2173 bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2174 bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2175
2176 bool is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
2177
2178 static const TypeAryKlassPtr* make(PTR ptr, const Type* elem, ciKlass* k, Offset offset, bool not_flat, bool not_null_free, bool flat, bool null_free, bool atomic, bool refined_type);
2179 static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);
2180
2181 const TypeAryKlassPtr* cast_to_non_refined() const;
2182 const TypeAryKlassPtr* cast_to_refined_array_klass_ptr(bool refined = true) const;
2183
2184 const Type *elem() const { return _elem; }
2185
2186 virtual bool eq(const Type *t) const;
2187 virtual uint hash() const; // Type specific hashing
2188
2189 virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
2190
2191 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
2192
2193 // corresponding pointer to instance, for a given class
2194 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
2195
2196 virtual const TypePtr *add_offset( intptr_t offset ) const;
2197 virtual const Type *xmeet( const Type *t ) const;
2198 virtual const Type *xdual() const; // Compute dual right now.
2199
2200 virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
2201
2202 virtual bool empty(void) const {
2203 return TypeKlassPtr::empty() || _elem->empty();
2204 }
2205
2206 bool is_flat() const { return _flat; }
2207 bool is_not_flat() const { return _not_flat; }
2208 bool is_null_free() const { return _null_free; }
2209 bool is_not_null_free() const { return _not_null_free; }
2210 bool is_atomic() const { return _atomic; }
2211 bool is_refined_type() const { return _refined_type; }
2212 virtual bool can_be_inline_array() const;
2213
2214 #ifndef PRODUCT
2215 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2216 #endif
2217 private:
2218 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
2219 };
2220
2221 class TypeNarrowPtr : public Type {
2222 protected:
2223 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
2224
2225 TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
2226 _ptrtype(ptrtype) {
2227 assert(ptrtype->offset() == 0 ||
2228 ptrtype->offset() == OffsetBot ||
2229 ptrtype->offset() == OffsetTop, "no real offsets");
2230 }
2231
2232 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
2233 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
2234 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
2235 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
2236 // Do not allow interface-vs.-noninterface joins to collapse to top.
2237 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
2238 public:
2239 virtual bool eq( const Type *t ) const;
2240 virtual uint hash() const; // Type specific hashing
2241 virtual bool singleton(void) const; // TRUE if type is a singleton
2242
2243 virtual const Type *xmeet( const Type *t ) const;
2244 virtual const Type *xdual() const; // Compute dual right now.
2245
2246 virtual intptr_t get_con() const;
2247
2248 virtual bool empty(void) const; // TRUE if type is vacuous
2249
2250 // returns the equivalent ptr type for this compressed pointer
2251 const TypePtr *get_ptrtype() const {
2252 return _ptrtype;
2253 }
2254
2255 bool is_known_instance() const {
2256 return _ptrtype->is_known_instance();
2257 }
2258
2259 #ifndef PRODUCT
2260 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2261 #endif
2262 };
2263
2264 //------------------------------TypeNarrowOop----------------------------------
2265 // A compressed reference to some kind of Oop. This type wraps around
2266 // a preexisting TypeOopPtr and forwards most of it's operations to
2267 // the underlying type. It's only real purpose is to track the
2268 // oopness of the compressed oop value when we expose the conversion
2269 // between the normal and the compressed form.
2270 class TypeNarrowOop : public TypeNarrowPtr {
2271 protected:
2272 TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
2273 }
2274
2275 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
2276 return t->isa_narrowoop();
2277 }
2278
2279 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
2280 return t->is_narrowoop();
2281 }
2282
2283 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
2284 return new TypeNarrowOop(t);
2285 }
2286
2287 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
2288 return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
2289 }
2290
2291 public:
2292
2293 static const TypeNarrowOop *make( const TypePtr* type);
2294
2295 static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
2296 return make(TypeOopPtr::make_from_constant(con, require_constant));
2297 }
2298
2299 static const TypeNarrowOop *BOTTOM;
2300 static const TypeNarrowOop *NULL_PTR;
2301
2302 virtual const TypeNarrowOop* remove_speculative() const;
2303 virtual const Type* cleanup_speculative() const;
2304
2305 #ifndef PRODUCT
2306 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2307 #endif
2308 };
2309
2310 //------------------------------TypeNarrowKlass----------------------------------
2311 // A compressed reference to klass pointer. This type wraps around a
2312 // preexisting TypeKlassPtr and forwards most of it's operations to
2313 // the underlying type.
2314 class TypeNarrowKlass : public TypeNarrowPtr {
2315 protected:
2316 TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
2317 }
2318
2319 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
2320 return t->isa_narrowklass();
2321 }
2322
2323 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
2324 return t->is_narrowklass();
2325 }
2326
2327 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
2328 return new TypeNarrowKlass(t);
2329 }
2330
2331 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
2332 return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
2333 }
2334
2335 public:
2336 static const TypeNarrowKlass *make( const TypePtr* type);
2337
2338 // static const TypeNarrowKlass *BOTTOM;
2339 static const TypeNarrowKlass *NULL_PTR;
2340
2341 #ifndef PRODUCT
2342 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2343 #endif
2344 };
2345
2346 //------------------------------TypeFunc---------------------------------------
2347 // Class of Array Types
2348 class TypeFunc : public Type {
2349 TypeFunc(const TypeTuple *domain_sig, const TypeTuple* domain_cc, const TypeTuple* range_sig, const TypeTuple* range_cc, bool scalarized_return)
2350 : Type(Function), _domain_sig(domain_sig), _domain_cc(domain_cc), _range_sig(range_sig), _range_cc(range_cc), _scalarized_return(scalarized_return) {}
2351 virtual bool eq( const Type *t ) const;
2352 virtual uint hash() const; // Type specific hashing
2353 virtual bool singleton(void) const; // TRUE if type is a singleton
2354 virtual bool empty(void) const; // TRUE if type is vacuous
2355
2356 // Domains of inputs: inline type arguments are not passed by
2357 // reference, instead each field of the inline type is passed as an
2358 // argument. We maintain 2 views of the argument list here: one
2359 // based on the signature (with an inline type argument as a single
2360 // slot), one based on the actual calling convention (with a value
2361 // type argument as a list of its fields).
2362 const TypeTuple* const _domain_sig;
2363 const TypeTuple* const _domain_cc;
2364 // Range of results. Similar to domains: an inline type result can be
2365 // returned in registers in which case range_cc lists all fields and
2366 // is the actual calling convention.
2367 const TypeTuple* const _range_sig;
2368 const TypeTuple* const _range_cc;
2369 const bool _scalarized_return;
2370
2371 public:
2372 // Constants are shared among ADLC and VM
2373 enum { Control = AdlcVMDeps::Control,
2374 I_O = AdlcVMDeps::I_O,
2375 Memory = AdlcVMDeps::Memory,
2376 FramePtr = AdlcVMDeps::FramePtr,
2377 ReturnAdr = AdlcVMDeps::ReturnAdr,
2378 Parms = AdlcVMDeps::Parms
2379 };
2380
2381
2382 // Accessors:
2383 const TypeTuple* domain_sig() const { return _domain_sig; }
2384 const TypeTuple* domain_cc() const { return _domain_cc; }
2385 const TypeTuple* range_sig() const { return _range_sig; }
2386 const TypeTuple* range_cc() const { return _range_cc; }
2387
2388 static const TypeFunc* make(ciMethod* method, bool is_call = true, bool is_osr_compilation = false);
2389 static const TypeFunc *make(const TypeTuple* domain_sig, const TypeTuple* domain_cc,
2390 const TypeTuple* range_sig, const TypeTuple* range_cc,
2391 bool scalarized_return = false);
2392 static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
2393
2394 virtual const Type *xmeet( const Type *t ) const;
2395 virtual const Type *xdual() const; // Compute dual right now.
2396
2397 BasicType return_type() const;
2398
2399 bool returns_inline_type_as_fields() const {
2400 // First condition is not sufficient because returned value class can be empty
2401 assert(_range_sig == _range_cc || _scalarized_return, "Only possible with scalarized return");
2402 return _scalarized_return;
2403 }
2404
2405 #ifndef PRODUCT
2406 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2407 #endif
2408 // Convenience common pre-built types.
2409 };
2410
2411 //------------------------------accessors--------------------------------------
2412 inline bool Type::is_ptr_to_narrowoop() const {
2413 #ifdef _LP64
2414 return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
2415 #else
2416 return false;
2417 #endif
2418 }
2419
2420 inline bool Type::is_ptr_to_narrowklass() const {
2421 #ifdef _LP64
2422 return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
2423 #else
2424 return false;
2425 #endif
2426 }
2427
2428 inline float Type::getf() const {
2429 assert( _base == FloatCon, "Not a FloatCon" );
2430 return ((TypeF*)this)->_f;
2431 }
2432
2433 inline short Type::geth() const {
2434 assert(_base == HalfFloatCon, "Not a HalfFloatCon");
2435 return ((TypeH*)this)->_f;
2436 }
2437
2438 inline double Type::getd() const {
2439 assert( _base == DoubleCon, "Not a DoubleCon" );
2440 return ((TypeD*)this)->_d;
2441 }
2442
2443 inline const TypeInteger *Type::is_integer(BasicType bt) const {
2444 assert((bt == T_INT && _base == Int) || (bt == T_LONG && _base == Long), "Not an Int");
2445 return (TypeInteger*)this;
2446 }
2447
2448 inline const TypeInteger *Type::isa_integer(BasicType bt) const {
2449 return (((bt == T_INT && _base == Int) || (bt == T_LONG && _base == Long)) ? (TypeInteger*)this : nullptr);
2450 }
2451
2452 inline const TypeInt *Type::is_int() const {
2453 assert( _base == Int, "Not an Int" );
2454 return (TypeInt*)this;
2455 }
2456
2457 inline const TypeInt *Type::isa_int() const {
2458 return ( _base == Int ? (TypeInt*)this : nullptr);
2459 }
2460
2461 inline const TypeLong *Type::is_long() const {
2462 assert( _base == Long, "Not a Long" );
2463 return (TypeLong*)this;
2464 }
2465
2466 inline const TypeLong *Type::isa_long() const {
2467 return ( _base == Long ? (TypeLong*)this : nullptr);
2468 }
2469
2470 inline const TypeH* Type::isa_half_float() const {
2471 return ((_base == HalfFloatTop ||
2472 _base == HalfFloatCon ||
2473 _base == HalfFloatBot) ? (TypeH*)this : nullptr);
2474 }
2475
2476 inline const TypeH* Type::is_half_float_constant() const {
2477 assert( _base == HalfFloatCon, "Not a HalfFloat" );
2478 return (TypeH*)this;
2479 }
2480
2481 inline const TypeH* Type::isa_half_float_constant() const {
2482 return (_base == HalfFloatCon ? (TypeH*)this : nullptr);
2483 }
2484
2485 inline const TypeF *Type::isa_float() const {
2486 return ((_base == FloatTop ||
2487 _base == FloatCon ||
2488 _base == FloatBot) ? (TypeF*)this : nullptr);
2489 }
2490
2491 inline const TypeF *Type::is_float_constant() const {
2492 assert( _base == FloatCon, "Not a Float" );
2493 return (TypeF*)this;
2494 }
2495
2496 inline const TypeF *Type::isa_float_constant() const {
2497 return ( _base == FloatCon ? (TypeF*)this : nullptr);
2498 }
2499
2500 inline const TypeD *Type::isa_double() const {
2501 return ((_base == DoubleTop ||
2502 _base == DoubleCon ||
2503 _base == DoubleBot) ? (TypeD*)this : nullptr);
2504 }
2505
2506 inline const TypeD *Type::is_double_constant() const {
2507 assert( _base == DoubleCon, "Not a Double" );
2508 return (TypeD*)this;
2509 }
2510
2511 inline const TypeD *Type::isa_double_constant() const {
2512 return ( _base == DoubleCon ? (TypeD*)this : nullptr);
2513 }
2514
2515 inline const TypeTuple *Type::is_tuple() const {
2516 assert( _base == Tuple, "Not a Tuple" );
2517 return (TypeTuple*)this;
2518 }
2519
2520 inline const TypeAry *Type::is_ary() const {
2521 assert( _base == Array , "Not an Array" );
2522 return (TypeAry*)this;
2523 }
2524
2525 inline const TypeAry *Type::isa_ary() const {
2526 return ((_base == Array) ? (TypeAry*)this : nullptr);
2527 }
2528
2529 inline const TypePVectMask *Type::is_pvectmask() const {
2530 assert( _base == VectorMask, "Not a Vector Mask" );
2531 return (TypePVectMask*)this;
2532 }
2533
2534 inline const TypePVectMask *Type::isa_pvectmask() const {
2535 return (_base == VectorMask) ? (TypePVectMask*)this : nullptr;
2536 }
2537
2538 inline const TypeVect *Type::is_vect() const {
2539 assert( _base >= VectorMask && _base <= VectorZ, "Not a Vector" );
2540 return (TypeVect*)this;
2541 }
2542
2543 inline const TypeVect *Type::isa_vect() const {
2544 return (_base >= VectorMask && _base <= VectorZ) ? (TypeVect*)this : nullptr;
2545 }
2546
2547 inline const TypePtr *Type::is_ptr() const {
2548 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
2549 assert(_base >= AnyPtr && _base <= AryKlassPtr, "Not a pointer");
2550 return (TypePtr*)this;
2551 }
2552
2553 inline const TypePtr *Type::isa_ptr() const {
2554 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
2555 return (_base >= AnyPtr && _base <= AryKlassPtr) ? (TypePtr*)this : nullptr;
2556 }
2557
2558 inline const TypeOopPtr *Type::is_oopptr() const {
2559 // OopPtr is the first and KlassPtr the last, with no non-oops between.
2560 assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
2561 return (TypeOopPtr*)this;
2562 }
2563
2564 inline const TypeOopPtr *Type::isa_oopptr() const {
2565 // OopPtr is the first and KlassPtr the last, with no non-oops between.
2566 return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : nullptr;
2567 }
2568
2569 inline const TypeRawPtr *Type::isa_rawptr() const {
2570 return (_base == RawPtr) ? (TypeRawPtr*)this : nullptr;
2571 }
2572
2573 inline const TypeRawPtr *Type::is_rawptr() const {
2574 assert( _base == RawPtr, "Not a raw pointer" );
2575 return (TypeRawPtr*)this;
2576 }
2577
2578 inline const TypeInstPtr *Type::isa_instptr() const {
2579 return (_base == InstPtr) ? (TypeInstPtr*)this : nullptr;
2580 }
2581
2582 inline const TypeInstPtr *Type::is_instptr() const {
2583 assert( _base == InstPtr, "Not an object pointer" );
2584 return (TypeInstPtr*)this;
2585 }
2586
2587 inline const TypeAryPtr *Type::isa_aryptr() const {
2588 return (_base == AryPtr) ? (TypeAryPtr*)this : nullptr;
2589 }
2590
2591 inline const TypeAryPtr *Type::is_aryptr() const {
2592 assert( _base == AryPtr, "Not an array pointer" );
2593 return (TypeAryPtr*)this;
2594 }
2595
2596 inline const TypeNarrowOop *Type::is_narrowoop() const {
2597 // OopPtr is the first and KlassPtr the last, with no non-oops between.
2598 assert(_base == NarrowOop, "Not a narrow oop" ) ;
2599 return (TypeNarrowOop*)this;
2600 }
2601
2602 inline const TypeNarrowOop *Type::isa_narrowoop() const {
2603 // OopPtr is the first and KlassPtr the last, with no non-oops between.
2604 return (_base == NarrowOop) ? (TypeNarrowOop*)this : nullptr;
2605 }
2606
2607 inline const TypeNarrowKlass *Type::is_narrowklass() const {
2608 assert(_base == NarrowKlass, "Not a narrow oop" ) ;
2609 return (TypeNarrowKlass*)this;
2610 }
2611
2612 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
2613 return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : nullptr;
2614 }
2615
2616 inline const TypeMetadataPtr *Type::is_metadataptr() const {
2617 // MetadataPtr is the first and CPCachePtr the last
2618 assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
2619 return (TypeMetadataPtr*)this;
2620 }
2621
2622 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
2623 return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : nullptr;
2624 }
2625
2626 inline const TypeKlassPtr *Type::isa_klassptr() const {
2627 return (_base >= KlassPtr && _base <= AryKlassPtr ) ? (TypeKlassPtr*)this : nullptr;
2628 }
2629
2630 inline const TypeKlassPtr *Type::is_klassptr() const {
2631 assert(_base >= KlassPtr && _base <= AryKlassPtr, "Not a klass pointer");
2632 return (TypeKlassPtr*)this;
2633 }
2634
2635 inline const TypeInstKlassPtr *Type::isa_instklassptr() const {
2636 return (_base == InstKlassPtr) ? (TypeInstKlassPtr*)this : nullptr;
2637 }
2638
2639 inline const TypeInstKlassPtr *Type::is_instklassptr() const {
2640 assert(_base == InstKlassPtr, "Not a klass pointer");
2641 return (TypeInstKlassPtr*)this;
2642 }
2643
2644 inline const TypeAryKlassPtr *Type::isa_aryklassptr() const {
2645 return (_base == AryKlassPtr) ? (TypeAryKlassPtr*)this : nullptr;
2646 }
2647
2648 inline const TypeAryKlassPtr *Type::is_aryklassptr() const {
2649 assert(_base == AryKlassPtr, "Not a klass pointer");
2650 return (TypeAryKlassPtr*)this;
2651 }
2652
2653 inline const TypePtr* Type::make_ptr() const {
2654 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
2655 ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
2656 isa_ptr());
2657 }
2658
2659 inline const TypeOopPtr* Type::make_oopptr() const {
2660 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
2661 }
2662
2663 inline const TypeNarrowOop* Type::make_narrowoop() const {
2664 return (_base == NarrowOop) ? is_narrowoop() :
2665 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2666 }
2667
2668 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2669 return (_base == NarrowKlass) ? is_narrowklass() :
2670 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2671 }
2672
2673 inline bool Type::is_floatingpoint() const {
2674 if( (_base == HalfFloatCon) || (_base == HalfFloatBot) ||
2675 (_base == FloatCon) || (_base == FloatBot) ||
2676 (_base == DoubleCon) || (_base == DoubleBot) )
2677 return true;
2678 return false;
2679 }
2680
2681 inline bool Type::is_inlinetypeptr() const {
2682 return isa_instptr() != nullptr && is_instptr()->instance_klass()->is_inlinetype();
2683 }
2684
2685 inline ciInlineKlass* Type::inline_klass() const {
2686 return make_ptr()->is_instptr()->instance_klass()->as_inline_klass();
2687 }
2688
2689 template <>
2690 inline const TypeInt* Type::cast<TypeInt>() const {
2691 return is_int();
2692 }
2693
2694 template <>
2695 inline const TypeLong* Type::cast<TypeLong>() const {
2696 return is_long();
2697 }
2698
2699 template <>
2700 inline const TypeInt* Type::try_cast<TypeInt>() const {
2701 return isa_int();
2702 }
2703
2704 template <>
2705 inline const TypeLong* Type::try_cast<TypeLong>() const {
2706 return isa_long();
2707 }
2708
2709 // ===============================================================
2710 // Things that need to be 64-bits in the 64-bit build but
2711 // 32-bits in the 32-bit build. Done this way to get full
2712 // optimization AND strong typing.
2713 #ifdef _LP64
2714
2715 // For type queries and asserts
2716 #define is_intptr_t is_long
2717 #define isa_intptr_t isa_long
2718 #define find_intptr_t_type find_long_type
2719 #define find_intptr_t_con find_long_con
2720 #define TypeX TypeLong
2721 #define Type_X Type::Long
2722 #define TypeX_X TypeLong::LONG
2723 #define TypeX_ZERO TypeLong::ZERO
2724 // For 'ideal_reg' machine registers
2725 #define Op_RegX Op_RegL
2726 // For phase->intcon variants
2727 #define MakeConX longcon
2728 #define ConXNode ConLNode
2729 // For array index arithmetic
2730 #define MulXNode MulLNode
2731 #define AndXNode AndLNode
2732 #define OrXNode OrLNode
2733 #define CmpXNode CmpLNode
2734 #define CmpUXNode CmpULNode
2735 #define SubXNode SubLNode
2736 #define LShiftXNode LShiftLNode
2737 // For object size computation:
2738 #define AddXNode AddLNode
2739 #define RShiftXNode RShiftLNode
2740 // For card marks and hashcodes
2741 #define URShiftXNode URShiftLNode
2742 // For pointer-sized accesses
2743 #define LoadXNode LoadLNode
2744 #define StoreXNode StoreLNode
2745 // Opcodes
2746 #define Op_LShiftX Op_LShiftL
2747 #define Op_AndX Op_AndL
2748 #define Op_AddX Op_AddL
2749 #define Op_SubX Op_SubL
2750 #define Op_XorX Op_XorL
2751 #define Op_URShiftX Op_URShiftL
2752 #define Op_LoadX Op_LoadL
2753 #define Op_StoreX Op_StoreL
2754 // conversions
2755 #define ConvI2X(x) ConvI2L(x)
2756 #define ConvL2X(x) (x)
2757 #define ConvX2I(x) ConvL2I(x)
2758 #define ConvX2L(x) (x)
2759 #define ConvX2UL(x) (x)
2760
2761 #else
2762
2763 // For type queries and asserts
2764 #define is_intptr_t is_int
2765 #define isa_intptr_t isa_int
2766 #define find_intptr_t_type find_int_type
2767 #define find_intptr_t_con find_int_con
2768 #define TypeX TypeInt
2769 #define Type_X Type::Int
2770 #define TypeX_X TypeInt::INT
2771 #define TypeX_ZERO TypeInt::ZERO
2772 // For 'ideal_reg' machine registers
2773 #define Op_RegX Op_RegI
2774 // For phase->intcon variants
2775 #define MakeConX intcon
2776 #define ConXNode ConINode
2777 // For array index arithmetic
2778 #define MulXNode MulINode
2779 #define AndXNode AndINode
2780 #define OrXNode OrINode
2781 #define CmpXNode CmpINode
2782 #define CmpUXNode CmpUNode
2783 #define SubXNode SubINode
2784 #define LShiftXNode LShiftINode
2785 // For object size computation:
2786 #define AddXNode AddINode
2787 #define RShiftXNode RShiftINode
2788 // For card marks and hashcodes
2789 #define URShiftXNode URShiftINode
2790 // For pointer-sized accesses
2791 #define LoadXNode LoadINode
2792 #define StoreXNode StoreINode
2793 // Opcodes
2794 #define Op_LShiftX Op_LShiftI
2795 #define Op_AndX Op_AndI
2796 #define Op_AddX Op_AddI
2797 #define Op_SubX Op_SubI
2798 #define Op_XorX Op_XorI
2799 #define Op_URShiftX Op_URShiftI
2800 #define Op_LoadX Op_LoadI
2801 #define Op_StoreX Op_StoreI
2802 // conversions
2803 #define ConvI2X(x) (x)
2804 #define ConvL2X(x) ConvL2I(x)
2805 #define ConvX2I(x) (x)
2806 #define ConvX2L(x) ConvI2L(x)
2807 #define ConvX2UL(x) ConvI2UL(x)
2808
2809 #endif
2810
2811 #endif // SHARE_OPTO_TYPE_HPP