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