0N/A/*
3845N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OPTO_TYPE_HPP
1879N/A#define SHARE_VM_OPTO_TYPE_HPP
1879N/A
1879N/A#include "libadt/port.hpp"
1879N/A#include "opto/adlcVMDeps.hpp"
1879N/A#include "runtime/handles.hpp"
1879N/A
0N/A// Portions of code courtesy of Clifford Click
0N/A
0N/A// Optimization - Graph Style
0N/A
0N/A
0N/A// This class defines a Type lattice. The lattice is used in the constant
0N/A// propagation algorithms, and for some type-checking of the iloc code.
0N/A// Basic types include RSD's (lower bound, upper bound, stride for integers),
0N/A// float & double precision constants, sets of data-labels and code-labels.
0N/A// The complete lattice is described below. Subtypes have no relationship to
0N/A// up or down in the lattice; that is entirely determined by the behavior of
0N/A// the MEET/JOIN functions.
0N/A
0N/Aclass Dict;
0N/Aclass Type;
0N/Aclass TypeD;
0N/Aclass TypeF;
0N/Aclass TypeInt;
0N/Aclass TypeLong;
113N/Aclass TypeNarrowOop;
0N/Aclass TypeAry;
0N/Aclass TypeTuple;
3845N/Aclass TypeVect;
3845N/Aclass TypeVectS;
3845N/Aclass TypeVectD;
3845N/Aclass TypeVectX;
3845N/Aclass TypeVectY;
0N/Aclass TypePtr;
0N/Aclass TypeRawPtr;
0N/Aclass TypeOopPtr;
0N/Aclass TypeInstPtr;
0N/Aclass TypeAryPtr;
0N/Aclass TypeKlassPtr;
0N/A
0N/A//------------------------------Type-------------------------------------------
0N/A// Basic Type object, represents a set of primitive Values.
0N/A// Types are hash-cons'd into a private class dictionary, so only one of each
0N/A// different kind of Type exists. Types are never modified after creation, so
0N/A// all their interesting fields are constant.
0N/Aclass Type {
2772N/A friend class VMStructs;
2772N/A
0N/Apublic:
0N/A enum TYPES {
0N/A Bad=0, // Type check
0N/A Control, // Control of code (not in lattice)
0N/A Top, // Top of the lattice
0N/A Int, // Integer range (lo-hi)
0N/A Long, // Long integer range (lo-hi)
0N/A Half, // Placeholder half of doubleword
113N/A NarrowOop, // Compressed oop pointer
0N/A
0N/A Tuple, // Method signature or object layout
0N/A Array, // Array types
3845N/A VectorS, // 32bit Vector types
3845N/A VectorD, // 64bit Vector types
3845N/A VectorX, // 128bit Vector types
3845N/A VectorY, // 256bit Vector types
0N/A
0N/A AnyPtr, // Any old raw, klass, inst, or array pointer
0N/A RawPtr, // Raw (non-oop) pointers
0N/A OopPtr, // Any and all Java heap entities
0N/A InstPtr, // Instance pointers (non-array objects)
0N/A AryPtr, // Array pointers
0N/A KlassPtr, // Klass pointers
0N/A // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
0N/A
0N/A Function, // Function signature
0N/A Abio, // Abstract I/O
0N/A Return_Address, // Subroutine return address
0N/A Memory, // Abstract store
0N/A FloatTop, // No float value
0N/A FloatCon, // Floating point constant
0N/A FloatBot, // Any float value
0N/A DoubleTop, // No double value
0N/A DoubleCon, // Double precision constant
0N/A DoubleBot, // Any double value
0N/A Bottom, // Bottom of lattice
0N/A lastype // Bogus ending type (not in lattice)
0N/A };
0N/A
0N/A // Signal values for offsets from a base pointer
0N/A enum OFFSET_SIGNALS {
0N/A OffsetTop = -2000000000, // undefined offset
0N/A OffsetBot = -2000000001 // any possible offset
0N/A };
0N/A
0N/A // Min and max WIDEN values.
0N/A enum WIDEN {
0N/A WidenMin = 0,
0N/A WidenMax = 3
0N/A };
0N/A
0N/Aprivate:
0N/A // Dictionary of types shared among compilations.
0N/A static Dict* _shared_type_dict;
0N/A
0N/A static int uhash( const Type *const t );
0N/A // Structural equality check. Assumes that cmp() has already compared
0N/A // the _base types and thus knows it can cast 't' appropriately.
0N/A virtual bool eq( const Type *t ) const;
0N/A
0N/A // Top-level hash-table of types
0N/A static Dict *type_dict() {
0N/A return Compile::current()->type_dict();
0N/A }
0N/A
0N/A // DUAL operation: reflect around lattice centerline. Used instead of
0N/A // join to ensure my lattice is symmetric up and down. Dual is computed
0N/A // lazily, on demand, and cached in _dual.
0N/A const Type *_dual; // Cached dual value
0N/A // Table for efficient dualing of base types
0N/A static const TYPES dual_type[lastype];
0N/A
0N/Aprotected:
0N/A // Each class of type is also identified by its base.
0N/A const TYPES _base; // Enum of Types type
0N/A
0N/A Type( TYPES t ) : _dual(NULL), _base(t) {} // Simple types
0N/A // ~Type(); // Use fast deallocation
0N/A const Type *hashcons(); // Hash-cons the type
0N/A
0N/Apublic:
0N/A
0N/A inline void* operator new( size_t x ) {
0N/A Compile* compile = Compile::current();
0N/A compile->set_type_last_size(x);
0N/A void *temp = compile->type_arena()->Amalloc_D(x);
0N/A compile->set_type_hwm(temp);
0N/A return temp;
0N/A }
0N/A inline void operator delete( void* ptr ) {
0N/A Compile* compile = Compile::current();
0N/A compile->type_arena()->Afree(ptr,compile->type_last_size());
0N/A }
0N/A
0N/A // Initialize the type system for a particular compilation.
0N/A static void Initialize(Compile* compile);
0N/A
0N/A // Initialize the types shared by all compilations.
0N/A static void Initialize_shared(Compile* compile);
0N/A
0N/A TYPES base() const {
0N/A assert(_base > Bad && _base < lastype, "sanity");
0N/A return _base;
0N/A }
0N/A
0N/A // Create a new hash-consd type
0N/A static const Type *make(enum TYPES);
0N/A // Test for equivalence of types
0N/A static int cmp( const Type *const t1, const Type *const t2 );
0N/A // Test for higher or equal in lattice
0N/A int higher_equal( const Type *t ) const { return !cmp(meet(t),t); }
0N/A
0N/A // MEET operation; lower in lattice.
0N/A const Type *meet( const Type *t ) const;
0N/A // WIDEN: 'widens' for Ints and other range types
1009N/A virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
0N/A // NARROW: complement for widen, used by pessimistic phases
0N/A virtual const Type *narrow( const Type *old ) const { return this; }
0N/A
0N/A // DUAL operation: reflect around lattice centerline. Used instead of
0N/A // join to ensure my lattice is symmetric up and down.
0N/A const Type *dual() const { return _dual; }
0N/A
0N/A // Compute meet dependent on base type
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A
0N/A // JOIN operation; higher in lattice. Done by finding the dual of the
0N/A // meet of the dual of the 2 inputs.
0N/A const Type *join( const Type *t ) const {
0N/A return dual()->meet(t->dual())->dual(); }
0N/A
0N/A // Modified version of JOIN adapted to the needs Node::Value.
0N/A // Normalizes all empty values to TOP. Does not kill _widen bits.
0N/A // Currently, it also works around limitations involving interface types.
0N/A virtual const Type *filter( const Type *kills ) const;
0N/A
820N/A#ifdef ASSERT
820N/A // One type is interface, the other is oop
820N/A virtual bool interface_vs_oop(const Type *t) const;
820N/A#endif
820N/A
113N/A // Returns true if this pointer points at memory which contains a
163N/A // compressed oop references.
163N/A bool is_ptr_to_narrowoop() const;
113N/A
0N/A // Convenience access
0N/A float getf() const;
0N/A double getd() const;
0N/A
0N/A const TypeInt *is_int() const;
0N/A const TypeInt *isa_int() const; // Returns NULL if not an Int
0N/A const TypeLong *is_long() const;
0N/A const TypeLong *isa_long() const; // Returns NULL if not a Long
4122N/A const TypeD *isa_double() const; // Returns NULL if not a Double{Top,Con,Bot}
0N/A const TypeD *is_double_constant() const; // Asserts it is a DoubleCon
0N/A const TypeD *isa_double_constant() const; // Returns NULL if not a DoubleCon
4122N/A const TypeF *isa_float() const; // Returns NULL if not a Float{Top,Con,Bot}
0N/A const TypeF *is_float_constant() const; // Asserts it is a FloatCon
0N/A const TypeF *isa_float_constant() const; // Returns NULL if not a FloatCon
0N/A const TypeTuple *is_tuple() const; // Collection of fields, NOT a pointer
0N/A const TypeAry *is_ary() const; // Array, NOT array pointer
3845N/A const TypeVect *is_vect() const; // Vector
3845N/A const TypeVect *isa_vect() const; // Returns NULL if not a Vector
0N/A const TypePtr *is_ptr() const; // Asserts it is a ptr type
0N/A const TypePtr *isa_ptr() const; // Returns NULL if not ptr type
113N/A const TypeRawPtr *isa_rawptr() const; // NOT Java oop
113N/A const TypeRawPtr *is_rawptr() const; // Asserts is rawptr
163N/A const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer
163N/A const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type
113N/A const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type
113N/A const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer
113N/A const TypeKlassPtr *isa_klassptr() const; // Returns NULL if not KlassPtr
113N/A const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr
113N/A const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr
113N/A const TypeInstPtr *is_instptr() const; // Instance
113N/A const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr
113N/A const TypeAryPtr *is_aryptr() const; // Array oop
0N/A virtual bool is_finite() const; // Has a finite value
0N/A virtual bool is_nan() const; // Is not a number (NaN)
0N/A
221N/A // Returns this ptr type or the equivalent ptr type for this compressed pointer.
221N/A const TypePtr* make_ptr() const;
827N/A
827N/A // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
827N/A // Asserts if the underlying type is not an oopptr or narrowoop.
827N/A const TypeOopPtr* make_oopptr() const;
827N/A
221N/A // Returns this compressed pointer or the equivalent compressed version
221N/A // of this pointer type.
221N/A const TypeNarrowOop* make_narrowoop() const;
221N/A
0N/A // Special test for register pressure heuristic
0N/A bool is_floatingpoint() const; // True if Float or Double base type
0N/A
0N/A // Do you have memory, directly or through a tuple?
0N/A bool has_memory( ) const;
0N/A
0N/A // Are you a pointer type or not?
0N/A bool isa_oop_ptr() const;
0N/A
0N/A // TRUE if type is a singleton
0N/A virtual bool singleton(void) const;
0N/A
0N/A // TRUE if type is above the lattice centerline, and is therefore vacuous
0N/A virtual bool empty(void) const;
0N/A
0N/A // Return a hash for this type. The hash function is public so ConNode
0N/A // (constants) can hash on their constant, which is represented by a Type.
0N/A virtual int hash() const;
0N/A
0N/A // Map ideal registers (machine types) to ideal types
0N/A static const Type *mreg2type[];
0N/A
0N/A // Printing, statistics
0N/A static const char * const msg[lastype]; // Printable strings
0N/A#ifndef PRODUCT
0N/A void dump_on(outputStream *st) const;
0N/A void dump() const {
0N/A dump_on(tty);
0N/A }
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
0N/A static void dump_stats();
0N/A static void verify_lastype(); // Check that arrays match type enum
0N/A#endif
0N/A void typerr(const Type *t) const; // Mixing types error
0N/A
0N/A // Create basic type
0N/A static const Type* get_const_basic_type(BasicType type) {
0N/A assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type");
0N/A return _const_basic_type[type];
0N/A }
0N/A
0N/A // Mapping to the array element's basic type.
0N/A BasicType array_element_basic_type() const;
0N/A
0N/A // Create standard type for a ciType:
0N/A static const Type* get_const_type(ciType* type);
0N/A
0N/A // Create standard zero value:
0N/A static const Type* get_zero_type(BasicType type) {
0N/A assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
0N/A return _zero_type[type];
0N/A }
0N/A
0N/A // Report if this is a zero value (not top).
0N/A bool is_zero_type() const {
0N/A BasicType type = basic_type();
0N/A if (type == T_VOID || type >= T_CONFLICT)
0N/A return false;
0N/A else
0N/A return (this == _zero_type[type]);
0N/A }
0N/A
0N/A // Convenience common pre-built types.
0N/A static const Type *ABIO;
0N/A static const Type *BOTTOM;
0N/A static const Type *CONTROL;
0N/A static const Type *DOUBLE;
0N/A static const Type *FLOAT;
0N/A static const Type *HALF;
0N/A static const Type *MEMORY;
0N/A static const Type *MULTI;
0N/A static const Type *RETURN_ADDRESS;
0N/A static const Type *TOP;
0N/A
0N/A // Mapping from compiler type to VM BasicType
0N/A BasicType basic_type() const { return _basic_type[_base]; }
0N/A
0N/A // Mapping from CI type system to compiler type:
0N/A static const Type* get_typeflow_type(ciType* type);
0N/A
0N/Aprivate:
0N/A // support arrays
0N/A static const BasicType _basic_type[];
0N/A static const Type* _zero_type[T_CONFLICT+1];
0N/A static const Type* _const_basic_type[T_CONFLICT+1];
0N/A};
0N/A
0N/A//------------------------------TypeF------------------------------------------
0N/A// Class of Float-Constant Types.
0N/Aclass TypeF : public Type {
0N/A TypeF( float f ) : Type(FloatCon), _f(f) {};
0N/Apublic:
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
0N/Apublic:
0N/A const float _f; // Float constant
0N/A
0N/A static const TypeF *make(float f);
0N/A
0N/A virtual bool is_finite() const; // Has a finite value
0N/A virtual bool is_nan() const; // Is not a number (NaN)
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A // Convenience common pre-built types.
0N/A static const TypeF *ZERO; // positive zero only
0N/A static const TypeF *ONE;
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeD------------------------------------------
0N/A// Class of Double-Constant Types.
0N/Aclass TypeD : public Type {
0N/A TypeD( double d ) : Type(DoubleCon), _d(d) {};
0N/Apublic:
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
0N/Apublic:
0N/A const double _d; // Double constant
0N/A
0N/A static const TypeD *make(double d);
0N/A
0N/A virtual bool is_finite() const; // Has a finite value
0N/A virtual bool is_nan() const; // Is not a number (NaN)
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A // Convenience common pre-built types.
0N/A static const TypeD *ZERO; // positive zero only
0N/A static const TypeD *ONE;
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeInt----------------------------------------
0N/A// Class of integer ranges, the set of integers between a lower bound and an
0N/A// upper bound, inclusive.
0N/Aclass TypeInt : public Type {
0N/A TypeInt( jint lo, jint hi, int w );
0N/Apublic:
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
0N/Apublic:
0N/A const jint _lo, _hi; // Lower bound, upper bound
0N/A const short _widen; // Limit on times we widen this sucker
0N/A
0N/A static const TypeInt *make(jint lo);
0N/A // must always specify w
0N/A static const TypeInt *make(jint lo, jint hi, int w);
0N/A
0N/A // Check for single integer
0N/A int is_con() const { return _lo==_hi; }
0N/A bool is_con(int i) const { return is_con() && _lo == i; }
0N/A jint get_con() const { assert( is_con(), "" ); return _lo; }
0N/A
0N/A virtual bool is_finite() const; // Has a finite value
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
1009N/A virtual const Type *widen( const Type *t, const Type* limit_type ) const;
0N/A virtual const Type *narrow( const Type *t ) const;
0N/A // Do not kill _widen bits.
0N/A virtual const Type *filter( const Type *kills ) const;
0N/A // Convenience common pre-built types.
0N/A static const TypeInt *MINUS_1;
0N/A static const TypeInt *ZERO;
0N/A static const TypeInt *ONE;
0N/A static const TypeInt *BOOL;
0N/A static const TypeInt *CC;
0N/A static const TypeInt *CC_LT; // [-1] == MINUS_1
0N/A static const TypeInt *CC_GT; // [1] == ONE
0N/A static const TypeInt *CC_EQ; // [0] == ZERO
0N/A static const TypeInt *CC_LE; // [-1,0]
0N/A static const TypeInt *CC_GE; // [0,1] == BOOL (!)
0N/A static const TypeInt *BYTE;
624N/A static const TypeInt *UBYTE;
0N/A static const TypeInt *CHAR;
0N/A static const TypeInt *SHORT;
0N/A static const TypeInt *POS;
0N/A static const TypeInt *POS1;
0N/A static const TypeInt *INT;
0N/A static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
0N/A#endif
0N/A};
0N/A
0N/A
0N/A//------------------------------TypeLong---------------------------------------
0N/A// Class of long integer ranges, the set of integers between a lower bound and
0N/A// an upper bound, inclusive.
0N/Aclass TypeLong : public Type {
0N/A TypeLong( jlong lo, jlong hi, int w );
0N/Apublic:
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
0N/Apublic:
0N/A const jlong _lo, _hi; // Lower bound, upper bound
0N/A const short _widen; // Limit on times we widen this sucker
0N/A
0N/A static const TypeLong *make(jlong lo);
0N/A // must always specify w
0N/A static const TypeLong *make(jlong lo, jlong hi, int w);
0N/A
0N/A // Check for single integer
0N/A int is_con() const { return _lo==_hi; }
145N/A bool is_con(int i) const { return is_con() && _lo == i; }
0N/A jlong get_con() const { assert( is_con(), "" ); return _lo; }
0N/A
0N/A virtual bool is_finite() const; // Has a finite value
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
1009N/A virtual const Type *widen( const Type *t, const Type* limit_type ) const;
0N/A virtual const Type *narrow( const Type *t ) const;
0N/A // Do not kill _widen bits.
0N/A virtual const Type *filter( const Type *kills ) const;
0N/A // Convenience common pre-built types.
0N/A static const TypeLong *MINUS_1;
0N/A static const TypeLong *ZERO;
0N/A static const TypeLong *ONE;
0N/A static const TypeLong *POS;
0N/A static const TypeLong *LONG;
0N/A static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint]
0N/A static const TypeLong *UINT; // 32-bit unsigned [0..max_juint]
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeTuple--------------------------------------
0N/A// Class of Tuple Types, essentially type collections for function signatures
0N/A// and class layouts. It happens to also be a fast cache for the HotSpot
0N/A// signature types.
0N/Aclass TypeTuple : public Type {
0N/A TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
0N/Apublic:
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
0N/A
0N/Apublic:
0N/A const uint _cnt; // Count of fields
0N/A const Type ** const _fields; // Array of field types
0N/A
0N/A // Accessors:
0N/A uint cnt() const { return _cnt; }
0N/A const Type* field_at(uint i) const {
0N/A assert(i < _cnt, "oob");
0N/A return _fields[i];
0N/A }
0N/A void set_field_at(uint i, const Type* t) {
0N/A assert(i < _cnt, "oob");
0N/A _fields[i] = t;
0N/A }
0N/A
0N/A static const TypeTuple *make( uint cnt, const Type **fields );
0N/A static const TypeTuple *make_range(ciSignature *sig);
0N/A static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
0N/A
0N/A // Subroutine call type with space allocated for argument types
0N/A static const Type **fields( uint arg_cnt );
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A // Convenience common pre-built types.
0N/A static const TypeTuple *IFBOTH;
0N/A static const TypeTuple *IFFALSE;
0N/A static const TypeTuple *IFTRUE;
0N/A static const TypeTuple *IFNEITHER;
0N/A static const TypeTuple *LOOPBODY;
0N/A static const TypeTuple *MEMBAR;
0N/A static const TypeTuple *STORECONDITIONAL;
0N/A static const TypeTuple *START_I2C;
0N/A static const TypeTuple *INT_PAIR;
0N/A static const TypeTuple *LONG_PAIR;
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeAry----------------------------------------
0N/A// Class of Array Types
0N/Aclass TypeAry : public Type {
0N/A TypeAry( const Type *elem, const TypeInt *size) : Type(Array),
0N/A _elem(elem), _size(size) {}
0N/Apublic:
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
0N/A
0N/Aprivate:
0N/A const Type *_elem; // Element type of array
0N/A const TypeInt *_size; // Elements in array
0N/A friend class TypeAryPtr;
0N/A
0N/Apublic:
0N/A static const TypeAry *make( const Type *elem, const TypeInt *size);
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A bool ary_must_be_exact() const; // true if arrays of such are never generic
820N/A#ifdef ASSERT
820N/A // One type is interface, the other is oop
820N/A virtual bool interface_vs_oop(const Type *t) const;
820N/A#endif
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
0N/A#endif
0N/A};
0N/A
3845N/A//------------------------------TypeVect---------------------------------------
3845N/A// Class of Vector Types
3845N/Aclass TypeVect : public Type {
3845N/A const Type* _elem; // Vector's element type
3845N/A const uint _length; // Elements in vector (power of 2)
3845N/A
3845N/Aprotected:
3845N/A TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
3845N/A _elem(elem), _length(length) {}
3845N/A
3845N/Apublic:
3845N/A const Type* element_type() const { return _elem; }
3845N/A BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
3845N/A uint length() const { return _length; }
3845N/A uint length_in_bytes() const {
3845N/A return _length * type2aelembytes(element_basic_type());
3845N/A }
3845N/A
3845N/A virtual bool eq(const Type *t) const;
3845N/A virtual int hash() const; // Type specific hashing
3845N/A virtual bool singleton(void) const; // TRUE if type is a singleton
3845N/A virtual bool empty(void) const; // TRUE if type is vacuous
3845N/A
3845N/A static const TypeVect *make(const BasicType elem_bt, uint length) {
3845N/A // Use bottom primitive type.
3845N/A return make(get_const_basic_type(elem_bt), length);
3845N/A }
3845N/A // Used directly by Replicate nodes to construct singleton vector.
3845N/A static const TypeVect *make(const Type* elem, uint length);
3845N/A
3845N/A virtual const Type *xmeet( const Type *t) const;
3845N/A virtual const Type *xdual() const; // Compute dual right now.
3845N/A
3845N/A static const TypeVect *VECTS;
3845N/A static const TypeVect *VECTD;
3845N/A static const TypeVect *VECTX;
3845N/A static const TypeVect *VECTY;
3845N/A
3845N/A#ifndef PRODUCT
3845N/A virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
3845N/A#endif
3845N/A};
3845N/A
3845N/Aclass TypeVectS : public TypeVect {
3845N/A friend class TypeVect;
3845N/A TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
3845N/A};
3845N/A
3845N/Aclass TypeVectD : public TypeVect {
3845N/A friend class TypeVect;
3845N/A TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
3845N/A};
3845N/A
3845N/Aclass TypeVectX : public TypeVect {
3845N/A friend class TypeVect;
3845N/A TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
3845N/A};
3845N/A
3845N/Aclass TypeVectY : public TypeVect {
3845N/A friend class TypeVect;
3845N/A TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
3845N/A};
3845N/A
0N/A//------------------------------TypePtr----------------------------------------
0N/A// Class of machine Pointer Types: raw data, instances or arrays.
0N/A// If the _base enum is AnyPtr, then this refers to all of the above.
0N/A// Otherwise the _base will indicate which subset of pointers is affected,
0N/A// and the class will be inherited from.
0N/Aclass TypePtr : public Type {
113N/A friend class TypeNarrowOop;
0N/Apublic:
0N/A enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
0N/Aprotected:
0N/A TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A static const PTR ptr_meet[lastPTR][lastPTR];
0N/A static const PTR ptr_dual[lastPTR];
0N/A static const char * const ptr_msg[lastPTR];
0N/A
0N/Apublic:
0N/A const int _offset; // Offset into oop, with TOP & BOT
0N/A const PTR _ptr; // Pointer equivalence class
0N/A
0N/A const int offset() const { return _offset; }
0N/A const PTR ptr() const { return _ptr; }
0N/A
0N/A static const TypePtr *make( TYPES t, PTR ptr, int offset );
0N/A
0N/A // Return a 'ptr' version of this type
0N/A virtual const Type *cast_to_ptr_type(PTR ptr) const;
0N/A
0N/A virtual intptr_t get_con() const;
0N/A
306N/A int xadd_offset( intptr_t offset ) const;
306N/A virtual const TypePtr *add_offset( intptr_t offset ) const;
0N/A
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A int meet_offset( int offset ) const;
0N/A int dual_offset( ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A
0N/A // meet, dual and join over pointer equivalence sets
0N/A PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
0N/A PTR dual_ptr() const { return ptr_dual[ptr()]; }
0N/A
0N/A // This is textually confusing unless one recalls that
0N/A // join(t) == dual()->meet(t->dual())->dual().
0N/A PTR join_ptr( const PTR in_ptr ) const {
0N/A return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
0N/A }
0N/A
0N/A // Tests for relation to centerline of type lattice:
0N/A static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
0N/A static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
0N/A // Convenience common pre-built types.
0N/A static const TypePtr *NULL_PTR;
0N/A static const TypePtr *NOTNULL;
0N/A static const TypePtr *BOTTOM;
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeRawPtr-------------------------------------
0N/A// Class of raw pointers, pointers to things other than Oops. Examples
0N/A// include the stack pointer, top of heap, card-marking area, handles, etc.
0N/Aclass TypeRawPtr : public TypePtr {
0N/Aprotected:
0N/A TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
0N/Apublic:
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A
0N/A const address _bits; // Constant value, if applicable
0N/A
0N/A static const TypeRawPtr *make( PTR ptr );
0N/A static const TypeRawPtr *make( address bits );
0N/A
0N/A // Return a 'ptr' version of this type
0N/A virtual const Type *cast_to_ptr_type(PTR ptr) const;
0N/A
0N/A virtual intptr_t get_con() const;
0N/A
306N/A virtual const TypePtr *add_offset( intptr_t offset ) const;
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A // Convenience common pre-built types.
0N/A static const TypeRawPtr *BOTTOM;
0N/A static const TypeRawPtr *NOTNULL;
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeOopPtr-------------------------------------
0N/A// Some kind of oop (Java pointer), either klass or instance or array.
0N/Aclass TypeOopPtr : public TypePtr {
0N/Aprotected:
163N/A TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id );
0N/Apublic:
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A enum {
223N/A InstanceTop = -1, // undefined instance
223N/A InstanceBot = 0 // any possible instance
0N/A };
0N/Aprotected:
0N/A
0N/A // Oop is NULL, unless this is a constant oop.
0N/A ciObject* _const_oop; // Constant oop
0N/A // If _klass is NULL, then so is _sig. This is an unloaded klass.
0N/A ciKlass* _klass; // Klass object
0N/A // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
0N/A bool _klass_is_exact;
163N/A bool _is_ptr_to_narrowoop;
0N/A
223N/A // If not InstanceTop or InstanceBot, indicates that this is
223N/A // a particular instance of this type which is distinct.
223N/A // This is the the node index of the allocation node creating this instance.
223N/A int _instance_id;
0N/A
0N/A static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
0N/A
223N/A int dual_instance_id() const;
223N/A int meet_instance_id(int uid) const;
0N/A
0N/Apublic:
0N/A // Creates a type given a klass. Correctly handles multi-dimensional arrays
0N/A // Respects UseUniqueSubclasses.
0N/A // If the klass is final, the resulting type will be exact.
0N/A static const TypeOopPtr* make_from_klass(ciKlass* klass) {
0N/A return make_from_klass_common(klass, true, false);
0N/A }
0N/A // Same as before, but will produce an exact type, even if
0N/A // the klass is not final, as long as it has exactly one implementation.
0N/A static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
0N/A return make_from_klass_common(klass, true, true);
0N/A }
0N/A // Same as before, but does not respects UseUniqueSubclasses.
0N/A // Use this only for creating array element types.
0N/A static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
0N/A return make_from_klass_common(klass, false, false);
0N/A }
0N/A // Creates a singleton type given an object.
989N/A // If the object cannot be rendered as a constant,
989N/A // may return a non-singleton type.
989N/A // If require_constant, produce a NULL if a singleton is not possible.
989N/A static const TypeOopPtr* make_from_constant(ciObject* o, bool require_constant = false);
0N/A
0N/A // Make a generic (unclassed) pointer to an oop.
992N/A static const TypeOopPtr* make(PTR ptr, int offset, int instance_id);
0N/A
0N/A ciObject* const_oop() const { return _const_oop; }
0N/A virtual ciKlass* klass() const { return _klass; }
0N/A bool klass_is_exact() const { return _klass_is_exact; }
163N/A
163N/A // Returns true if this pointer points at memory which contains a
163N/A // compressed oop references.
163N/A bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
163N/A
223N/A bool is_known_instance() const { return _instance_id > 0; }
223N/A int instance_id() const { return _instance_id; }
223N/A bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
0N/A
0N/A virtual intptr_t get_con() const;
0N/A
0N/A virtual const Type *cast_to_ptr_type(PTR ptr) const;
0N/A
0N/A virtual const Type *cast_to_exactness(bool klass_is_exact) const;
0N/A
223N/A virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
0N/A
0N/A // corresponding pointer to klass, for a given instance
0N/A const TypeKlassPtr* as_klass_type() const;
0N/A
306N/A virtual const TypePtr *add_offset( intptr_t offset ) const;
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A
0N/A // Do not allow interface-vs.-noninterface joins to collapse to top.
0N/A virtual const Type *filter( const Type *kills ) const;
0N/A
0N/A // Convenience common pre-built type.
0N/A static const TypeOopPtr *BOTTOM;
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeInstPtr------------------------------------
0N/A// Class of Java object pointers, pointing either to non-array Java instances
0N/A// or to a klassOop (including array klasses).
0N/Aclass TypeInstPtr : public TypeOopPtr {
0N/A TypeInstPtr( PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id );
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A
0N/A ciSymbol* _name; // class name
0N/A
0N/A public:
0N/A ciSymbol* name() const { return _name; }
0N/A
0N/A bool is_loaded() const { return _klass->is_loaded(); }
0N/A
0N/A // Make a pointer to a constant oop.
0N/A static const TypeInstPtr *make(ciObject* o) {
0N/A return make(TypePtr::Constant, o->klass(), true, o, 0);
0N/A }
0N/A
0N/A // Make a pointer to a constant oop with offset.
0N/A static const TypeInstPtr *make(ciObject* o, int offset) {
0N/A return make(TypePtr::Constant, o->klass(), true, o, offset);
0N/A }
0N/A
0N/A // Make a pointer to some value of type klass.
0N/A static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
0N/A return make(ptr, klass, false, NULL, 0);
0N/A }
0N/A
0N/A // Make a pointer to some non-polymorphic value of exactly type klass.
0N/A static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
0N/A return make(ptr, klass, true, NULL, 0);
0N/A }
0N/A
0N/A // Make a pointer to some value of type klass with offset.
0N/A static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
0N/A return make(ptr, klass, false, NULL, offset);
0N/A }
0N/A
0N/A // Make a pointer to an oop.
223N/A static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot );
0N/A
0N/A // If this is a java.lang.Class constant, return the type for it or NULL.
0N/A // Pass to Type::get_const_type to turn it to a type, which will usually
0N/A // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
0N/A ciType* java_mirror_type() const;
0N/A
0N/A virtual const Type *cast_to_ptr_type(PTR ptr) const;
0N/A
0N/A virtual const Type *cast_to_exactness(bool klass_is_exact) const;
0N/A
223N/A virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
0N/A
306N/A virtual const TypePtr *add_offset( intptr_t offset ) const;
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A
0N/A // Convenience common pre-built types.
0N/A static const TypeInstPtr *NOTNULL;
0N/A static const TypeInstPtr *BOTTOM;
0N/A static const TypeInstPtr *MIRROR;
0N/A static const TypeInstPtr *MARK;
0N/A static const TypeInstPtr *KLASS;
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeAryPtr-------------------------------------
0N/A// Class of Java array pointers
0N/Aclass TypeAryPtr : public TypeOopPtr {
1681N/A TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id), _ary(ary) {
1681N/A#ifdef ASSERT
1681N/A if (k != NULL) {
1681N/A // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1681N/A ciKlass* ck = compute_klass(true);
1712N/A if (k != ck) {
1681N/A this->dump(); tty->cr();
1681N/A tty->print(" k: ");
1681N/A k->print(); tty->cr();
1681N/A tty->print("ck: ");
1681N/A if (ck != NULL) ck->print();
1681N/A else tty->print("<NULL>");
1681N/A tty->cr();
1681N/A assert(false, "unexpected TypeAryPtr::_klass");
1681N/A }
1681N/A }
1681N/A#endif
1681N/A }
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A const TypeAry *_ary; // Array we point into
0N/A
1681N/A ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1681N/A
0N/Apublic:
0N/A // Accessors
0N/A ciKlass* klass() const;
0N/A const TypeAry* ary() const { return _ary; }
0N/A const Type* elem() const { return _ary->_elem; }
0N/A const TypeInt* size() const { return _ary->_size; }
0N/A
223N/A static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot);
0N/A // Constant pointer to array
223N/A static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot);
0N/A
0N/A // Return a 'ptr' version of this type
0N/A virtual const Type *cast_to_ptr_type(PTR ptr) const;
0N/A
0N/A virtual const Type *cast_to_exactness(bool klass_is_exact) const;
0N/A
223N/A virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
0N/A
0N/A virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
366N/A virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
0N/A
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
306N/A virtual const TypePtr *add_offset( intptr_t offset ) const;
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A
0N/A // Convenience common pre-built types.
0N/A static const TypeAryPtr *RANGE;
0N/A static const TypeAryPtr *OOPS;
163N/A static const TypeAryPtr *NARROWOOPS;
0N/A static const TypeAryPtr *BYTES;
0N/A static const TypeAryPtr *SHORTS;
0N/A static const TypeAryPtr *CHARS;
0N/A static const TypeAryPtr *INTS;
0N/A static const TypeAryPtr *LONGS;
0N/A static const TypeAryPtr *FLOATS;
0N/A static const TypeAryPtr *DOUBLES;
0N/A // selects one of the above:
0N/A static const TypeAryPtr *get_array_body_type(BasicType elem) {
0N/A assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
0N/A return _array_body_type[elem];
0N/A }
0N/A static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
0N/A // sharpen the type of an int which is used as an array size
820N/A#ifdef ASSERT
820N/A // One type is interface, the other is oop
820N/A virtual bool interface_vs_oop(const Type *t) const;
820N/A#endif
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
0N/A#endif
0N/A};
0N/A
0N/A//------------------------------TypeKlassPtr-----------------------------------
0N/A// Class of Java Klass pointers
0N/Aclass TypeKlassPtr : public TypeOopPtr {
0N/A TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
0N/A
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A
0N/Apublic:
0N/A ciSymbol* name() const { return _klass->name(); }
0N/A
555N/A bool is_loaded() const { return _klass->is_loaded(); }
555N/A
0N/A // ptr to klass 'k'
0N/A static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
0N/A // ptr to klass 'k' with offset
0N/A static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
0N/A // ptr to klass 'k' or sub-klass
0N/A static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
0N/A
0N/A virtual const Type *cast_to_ptr_type(PTR ptr) const;
0N/A
0N/A virtual const Type *cast_to_exactness(bool klass_is_exact) const;
0N/A
0N/A // corresponding pointer to instance, for a given class
0N/A const TypeOopPtr* as_instance_type() const;
0N/A
306N/A virtual const TypePtr *add_offset( intptr_t offset ) const;
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A
0N/A // Convenience common pre-built types.
0N/A static const TypeKlassPtr* OBJECT; // Not-null object klass or below
0N/A static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
0N/A#endif
0N/A};
0N/A
163N/A//------------------------------TypeNarrowOop----------------------------------
113N/A// A compressed reference to some kind of Oop. This type wraps around
113N/A// a preexisting TypeOopPtr and forwards most of it's operations to
113N/A// the underlying type. It's only real purpose is to track the
113N/A// oopness of the compressed oop value when we expose the conversion
113N/A// between the normal and the compressed form.
113N/Aclass TypeNarrowOop : public Type {
113N/Aprotected:
827N/A const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
113N/A
827N/A TypeNarrowOop( const TypePtr* ptrtype): Type(NarrowOop),
827N/A _ptrtype(ptrtype) {
827N/A assert(ptrtype->offset() == 0 ||
827N/A ptrtype->offset() == OffsetBot ||
827N/A ptrtype->offset() == OffsetTop, "no real offsets");
113N/A }
113N/Apublic:
113N/A virtual bool eq( const Type *t ) const;
113N/A virtual int hash() const; // Type specific hashing
113N/A virtual bool singleton(void) const; // TRUE if type is a singleton
113N/A
113N/A virtual const Type *xmeet( const Type *t ) const;
113N/A virtual const Type *xdual() const; // Compute dual right now.
113N/A
113N/A virtual intptr_t get_con() const;
113N/A
113N/A // Do not allow interface-vs.-noninterface joins to collapse to top.
113N/A virtual const Type *filter( const Type *kills ) const;
113N/A
113N/A virtual bool empty(void) const; // TRUE if type is vacuous
113N/A
113N/A static const TypeNarrowOop *make( const TypePtr* type);
113N/A
2226N/A static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
2226N/A return make(TypeOopPtr::make_from_constant(con, require_constant));
113N/A }
113N/A
221N/A // returns the equivalent ptr type for this compressed pointer
827N/A const TypePtr *get_ptrtype() const {
827N/A return _ptrtype;
113N/A }
113N/A
113N/A static const TypeNarrowOop *BOTTOM;
113N/A static const TypeNarrowOop *NULL_PTR;
113N/A
113N/A#ifndef PRODUCT
113N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
113N/A#endif
113N/A};
113N/A
0N/A//------------------------------TypeFunc---------------------------------------
0N/A// Class of Array Types
0N/Aclass TypeFunc : public Type {
0N/A TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function), _domain(domain), _range(range) {}
0N/A virtual bool eq( const Type *t ) const;
0N/A virtual int hash() const; // Type specific hashing
0N/A virtual bool singleton(void) const; // TRUE if type is a singleton
0N/A virtual bool empty(void) const; // TRUE if type is vacuous
0N/Apublic:
0N/A // Constants are shared among ADLC and VM
0N/A enum { Control = AdlcVMDeps::Control,
0N/A I_O = AdlcVMDeps::I_O,
0N/A Memory = AdlcVMDeps::Memory,
0N/A FramePtr = AdlcVMDeps::FramePtr,
0N/A ReturnAdr = AdlcVMDeps::ReturnAdr,
0N/A Parms = AdlcVMDeps::Parms
0N/A };
0N/A
0N/A const TypeTuple* const _domain; // Domain of inputs
0N/A const TypeTuple* const _range; // Range of results
0N/A
0N/A // Accessors:
0N/A const TypeTuple* domain() const { return _domain; }
0N/A const TypeTuple* range() const { return _range; }
0N/A
0N/A static const TypeFunc *make(ciMethod* method);
0N/A static const TypeFunc *make(ciSignature signature, const Type* extra);
0N/A static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
0N/A
0N/A virtual const Type *xmeet( const Type *t ) const;
0N/A virtual const Type *xdual() const; // Compute dual right now.
0N/A
0N/A BasicType return_type() const;
0N/A
0N/A#ifndef PRODUCT
0N/A virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
0N/A void print_flattened() const; // Print a 'flattened' signature
0N/A#endif
0N/A // Convenience common pre-built types.
0N/A};
0N/A
0N/A//------------------------------accessors--------------------------------------
163N/Ainline bool Type::is_ptr_to_narrowoop() const {
163N/A#ifdef _LP64
163N/A return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
163N/A#else
163N/A return false;
163N/A#endif
163N/A}
163N/A
0N/Ainline float Type::getf() const {
0N/A assert( _base == FloatCon, "Not a FloatCon" );
0N/A return ((TypeF*)this)->_f;
0N/A}
0N/A
0N/Ainline double Type::getd() const {
0N/A assert( _base == DoubleCon, "Not a DoubleCon" );
0N/A return ((TypeD*)this)->_d;
0N/A}
0N/A
0N/Ainline const TypeInt *Type::is_int() const {
0N/A assert( _base == Int, "Not an Int" );
0N/A return (TypeInt*)this;
0N/A}
0N/A
0N/Ainline const TypeInt *Type::isa_int() const {
0N/A return ( _base == Int ? (TypeInt*)this : NULL);
0N/A}
0N/A
0N/Ainline const TypeLong *Type::is_long() const {
0N/A assert( _base == Long, "Not a Long" );
0N/A return (TypeLong*)this;
0N/A}
0N/A
0N/Ainline const TypeLong *Type::isa_long() const {
0N/A return ( _base == Long ? (TypeLong*)this : NULL);
0N/A}
0N/A
4122N/Ainline const TypeF *Type::isa_float() const {
4122N/A return ((_base == FloatTop ||
4122N/A _base == FloatCon ||
4122N/A _base == FloatBot) ? (TypeF*)this : NULL);
4122N/A}
4122N/A
4122N/Ainline const TypeF *Type::is_float_constant() const {
4122N/A assert( _base == FloatCon, "Not a Float" );
4122N/A return (TypeF*)this;
4122N/A}
4122N/A
4122N/Ainline const TypeF *Type::isa_float_constant() const {
4122N/A return ( _base == FloatCon ? (TypeF*)this : NULL);
4122N/A}
4122N/A
4122N/Ainline const TypeD *Type::isa_double() const {
4122N/A return ((_base == DoubleTop ||
4122N/A _base == DoubleCon ||
4122N/A _base == DoubleBot) ? (TypeD*)this : NULL);
4122N/A}
4122N/A
4122N/Ainline const TypeD *Type::is_double_constant() const {
4122N/A assert( _base == DoubleCon, "Not a Double" );
4122N/A return (TypeD*)this;
4122N/A}
4122N/A
4122N/Ainline const TypeD *Type::isa_double_constant() const {
4122N/A return ( _base == DoubleCon ? (TypeD*)this : NULL);
4122N/A}
4122N/A
0N/Ainline const TypeTuple *Type::is_tuple() const {
0N/A assert( _base == Tuple, "Not a Tuple" );
0N/A return (TypeTuple*)this;
0N/A}
0N/A
0N/Ainline const TypeAry *Type::is_ary() const {
0N/A assert( _base == Array , "Not an Array" );
0N/A return (TypeAry*)this;
0N/A}
0N/A
3845N/Ainline const TypeVect *Type::is_vect() const {
3845N/A assert( _base >= VectorS && _base <= VectorY, "Not a Vector" );
3845N/A return (TypeVect*)this;
3845N/A}
3845N/A
3845N/Ainline const TypeVect *Type::isa_vect() const {
3845N/A return (_base >= VectorS && _base <= VectorY) ? (TypeVect*)this : NULL;
3845N/A}
3845N/A
0N/Ainline const TypePtr *Type::is_ptr() const {
0N/A // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
0N/A assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
0N/A return (TypePtr*)this;
0N/A}
0N/A
0N/Ainline const TypePtr *Type::isa_ptr() const {
0N/A // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
0N/A return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
0N/A}
0N/A
0N/Ainline const TypeOopPtr *Type::is_oopptr() const {
0N/A // OopPtr is the first and KlassPtr the last, with no non-oops between.
0N/A assert(_base >= OopPtr && _base <= KlassPtr, "Not a Java pointer" ) ;
0N/A return (TypeOopPtr*)this;
0N/A}
0N/A
0N/Ainline const TypeOopPtr *Type::isa_oopptr() const {
0N/A // OopPtr is the first and KlassPtr the last, with no non-oops between.
0N/A return (_base >= OopPtr && _base <= KlassPtr) ? (TypeOopPtr*)this : NULL;
0N/A}
0N/A
113N/Ainline const TypeRawPtr *Type::isa_rawptr() const {
113N/A return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
113N/A}
113N/A
0N/Ainline const TypeRawPtr *Type::is_rawptr() const {
0N/A assert( _base == RawPtr, "Not a raw pointer" );
0N/A return (TypeRawPtr*)this;
0N/A}
0N/A
0N/Ainline const TypeInstPtr *Type::isa_instptr() const {
0N/A return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
0N/A}
0N/A
0N/Ainline const TypeInstPtr *Type::is_instptr() const {
0N/A assert( _base == InstPtr, "Not an object pointer" );
0N/A return (TypeInstPtr*)this;
0N/A}
0N/A
0N/Ainline const TypeAryPtr *Type::isa_aryptr() const {
0N/A return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
0N/A}
0N/A
0N/Ainline const TypeAryPtr *Type::is_aryptr() const {
0N/A assert( _base == AryPtr, "Not an array pointer" );
0N/A return (TypeAryPtr*)this;
0N/A}
0N/A
113N/Ainline const TypeNarrowOop *Type::is_narrowoop() const {
113N/A // OopPtr is the first and KlassPtr the last, with no non-oops between.
113N/A assert(_base == NarrowOop, "Not a narrow oop" ) ;
113N/A return (TypeNarrowOop*)this;
113N/A}
113N/A
113N/Ainline const TypeNarrowOop *Type::isa_narrowoop() const {
113N/A // OopPtr is the first and KlassPtr the last, with no non-oops between.
113N/A return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
113N/A}
113N/A
0N/Ainline const TypeKlassPtr *Type::isa_klassptr() const {
0N/A return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
0N/A}
0N/A
0N/Ainline const TypeKlassPtr *Type::is_klassptr() const {
0N/A assert( _base == KlassPtr, "Not a klass pointer" );
0N/A return (TypeKlassPtr*)this;
0N/A}
0N/A
221N/Ainline const TypePtr* Type::make_ptr() const {
827N/A return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
221N/A (isa_ptr() ? is_ptr() : NULL);
221N/A}
221N/A
827N/Ainline const TypeOopPtr* Type::make_oopptr() const {
827N/A return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
827N/A}
827N/A
221N/Ainline const TypeNarrowOop* Type::make_narrowoop() const {
221N/A return (_base == NarrowOop) ? is_narrowoop() :
221N/A (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
221N/A}
221N/A
0N/Ainline bool Type::is_floatingpoint() const {
0N/A if( (_base == FloatCon) || (_base == FloatBot) ||
0N/A (_base == DoubleCon) || (_base == DoubleBot) )
0N/A return true;
0N/A return false;
0N/A}
0N/A
0N/A
0N/A// ===============================================================
0N/A// Things that need to be 64-bits in the 64-bit build but
0N/A// 32-bits in the 32-bit build. Done this way to get full
0N/A// optimization AND strong typing.
0N/A#ifdef _LP64
0N/A
0N/A// For type queries and asserts
0N/A#define is_intptr_t is_long
0N/A#define isa_intptr_t isa_long
0N/A#define find_intptr_t_type find_long_type
0N/A#define find_intptr_t_con find_long_con
0N/A#define TypeX TypeLong
0N/A#define Type_X Type::Long
0N/A#define TypeX_X TypeLong::LONG
0N/A#define TypeX_ZERO TypeLong::ZERO
0N/A// For 'ideal_reg' machine registers
0N/A#define Op_RegX Op_RegL
0N/A// For phase->intcon variants
0N/A#define MakeConX longcon
0N/A#define ConXNode ConLNode
0N/A// For array index arithmetic
0N/A#define MulXNode MulLNode
0N/A#define AndXNode AndLNode
0N/A#define OrXNode OrLNode
0N/A#define CmpXNode CmpLNode
0N/A#define SubXNode SubLNode
0N/A#define LShiftXNode LShiftLNode
0N/A// For object size computation:
0N/A#define AddXNode AddLNode
17N/A#define RShiftXNode RShiftLNode
0N/A// For card marks and hashcodes
0N/A#define URShiftXNode URShiftLNode
420N/A// UseOptoBiasInlining
420N/A#define XorXNode XorLNode
420N/A#define StoreXConditionalNode StoreLConditionalNode
0N/A// Opcodes
0N/A#define Op_LShiftX Op_LShiftL
0N/A#define Op_AndX Op_AndL
0N/A#define Op_AddX Op_AddL
0N/A#define Op_SubX Op_SubL
851N/A#define Op_XorX Op_XorL
851N/A#define Op_URShiftX Op_URShiftL
0N/A// conversions
0N/A#define ConvI2X(x) ConvI2L(x)
0N/A#define ConvL2X(x) (x)
0N/A#define ConvX2I(x) ConvL2I(x)
0N/A#define ConvX2L(x) (x)
0N/A
0N/A#else
0N/A
0N/A// For type queries and asserts
0N/A#define is_intptr_t is_int
0N/A#define isa_intptr_t isa_int
0N/A#define find_intptr_t_type find_int_type
0N/A#define find_intptr_t_con find_int_con
0N/A#define TypeX TypeInt
0N/A#define Type_X Type::Int
0N/A#define TypeX_X TypeInt::INT
0N/A#define TypeX_ZERO TypeInt::ZERO
0N/A// For 'ideal_reg' machine registers
0N/A#define Op_RegX Op_RegI
0N/A// For phase->intcon variants
0N/A#define MakeConX intcon
0N/A#define ConXNode ConINode
0N/A// For array index arithmetic
0N/A#define MulXNode MulINode
0N/A#define AndXNode AndINode
0N/A#define OrXNode OrINode
0N/A#define CmpXNode CmpINode
0N/A#define SubXNode SubINode
0N/A#define LShiftXNode LShiftINode
0N/A// For object size computation:
0N/A#define AddXNode AddINode
17N/A#define RShiftXNode RShiftINode
0N/A// For card marks and hashcodes
0N/A#define URShiftXNode URShiftINode
420N/A// UseOptoBiasInlining
420N/A#define XorXNode XorINode
420N/A#define StoreXConditionalNode StoreIConditionalNode
0N/A// Opcodes
0N/A#define Op_LShiftX Op_LShiftI
0N/A#define Op_AndX Op_AndI
0N/A#define Op_AddX Op_AddI
0N/A#define Op_SubX Op_SubI
851N/A#define Op_XorX Op_XorI
851N/A#define Op_URShiftX Op_URShiftI
0N/A// conversions
0N/A#define ConvI2X(x) (x)
0N/A#define ConvL2X(x) ConvL2I(x)
0N/A#define ConvX2I(x) (x)
0N/A#define ConvX2L(x) ConvI2L(x)
0N/A
0N/A#endif
1879N/A
1879N/A#endif // SHARE_VM_OPTO_TYPE_HPP