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#include "precompiled.hpp"
1879N/A#include "ci/ciTypeFlow.hpp"
1879N/A#include "classfile/symbolTable.hpp"
1879N/A#include "classfile/systemDictionary.hpp"
1879N/A#include "compiler/compileLog.hpp"
1879N/A#include "libadt/dict.hpp"
1879N/A#include "memory/gcLocker.hpp"
1879N/A#include "memory/oopFactory.hpp"
1879N/A#include "memory/resourceArea.hpp"
1879N/A#include "oops/instanceKlass.hpp"
2223N/A#include "oops/instanceMirrorKlass.hpp"
1879N/A#include "oops/klassKlass.hpp"
1879N/A#include "oops/objArrayKlass.hpp"
1879N/A#include "oops/typeArrayKlass.hpp"
1879N/A#include "opto/matcher.hpp"
1879N/A#include "opto/node.hpp"
1879N/A#include "opto/opcodes.hpp"
1879N/A#include "opto/type.hpp"
1879N/A
0N/A// Portions of code courtesy of Clifford Click
0N/A
0N/A// Optimization - Graph Style
0N/A
0N/A// Dictionary of types shared among compilations.
0N/ADict* Type::_shared_type_dict = NULL;
0N/A
0N/A// Array which maps compiler types to Basic Types
0N/Aconst BasicType Type::_basic_type[Type::lastype] = {
0N/A T_ILLEGAL, // Bad
0N/A T_ILLEGAL, // Control
0N/A T_VOID, // Top
0N/A T_INT, // Int
0N/A T_LONG, // Long
0N/A T_VOID, // Half
113N/A T_NARROWOOP, // NarrowOop
0N/A
0N/A T_ILLEGAL, // Tuple
0N/A T_ARRAY, // Array
3845N/A T_ILLEGAL, // VectorS
3845N/A T_ILLEGAL, // VectorD
3845N/A T_ILLEGAL, // VectorX
3845N/A T_ILLEGAL, // VectorY
0N/A
0N/A T_ADDRESS, // AnyPtr // shows up in factory methods for NULL_PTR
0N/A T_ADDRESS, // RawPtr
0N/A T_OBJECT, // OopPtr
0N/A T_OBJECT, // InstPtr
0N/A T_OBJECT, // AryPtr
0N/A T_OBJECT, // KlassPtr
0N/A
0N/A T_OBJECT, // Function
0N/A T_ILLEGAL, // Abio
0N/A T_ADDRESS, // Return_Address
0N/A T_ILLEGAL, // Memory
0N/A T_FLOAT, // FloatTop
0N/A T_FLOAT, // FloatCon
0N/A T_FLOAT, // FloatBot
0N/A T_DOUBLE, // DoubleTop
0N/A T_DOUBLE, // DoubleCon
0N/A T_DOUBLE, // DoubleBot
0N/A T_ILLEGAL, // Bottom
0N/A};
0N/A
0N/A// Map ideal registers (machine types) to ideal types
0N/Aconst Type *Type::mreg2type[_last_machine_leaf];
0N/A
0N/A// Map basic types to canonical Type* pointers.
0N/Aconst Type* Type:: _const_basic_type[T_CONFLICT+1];
0N/A
0N/A// Map basic types to constant-zero Types.
0N/Aconst Type* Type:: _zero_type[T_CONFLICT+1];
0N/A
0N/A// Map basic types to array-body alias types.
0N/Aconst TypeAryPtr* TypeAryPtr::_array_body_type[T_CONFLICT+1];
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst Type *Type::ABIO; // State-of-machine only
0N/Aconst Type *Type::BOTTOM; // All values
0N/Aconst Type *Type::CONTROL; // Control only
0N/Aconst Type *Type::DOUBLE; // All doubles
0N/Aconst Type *Type::FLOAT; // All floats
0N/Aconst Type *Type::HALF; // Placeholder half of doublewide type
0N/Aconst Type *Type::MEMORY; // Abstract store only
0N/Aconst Type *Type::RETURN_ADDRESS;
0N/Aconst Type *Type::TOP; // No values in set
0N/A
0N/A//------------------------------get_const_type---------------------------
0N/Aconst Type* Type::get_const_type(ciType* type) {
0N/A if (type == NULL) {
0N/A return NULL;
0N/A } else if (type->is_primitive_type()) {
0N/A return get_const_basic_type(type->basic_type());
0N/A } else {
0N/A return TypeOopPtr::make_from_klass(type->as_klass());
0N/A }
0N/A}
0N/A
0N/A//---------------------------array_element_basic_type---------------------------------
0N/A// Mapping to the array element's basic type.
0N/ABasicType Type::array_element_basic_type() const {
0N/A BasicType bt = basic_type();
0N/A if (bt == T_INT) {
0N/A if (this == TypeInt::INT) return T_INT;
0N/A if (this == TypeInt::CHAR) return T_CHAR;
0N/A if (this == TypeInt::BYTE) return T_BYTE;
0N/A if (this == TypeInt::BOOL) return T_BOOLEAN;
0N/A if (this == TypeInt::SHORT) return T_SHORT;
0N/A return T_VOID;
0N/A }
0N/A return bt;
0N/A}
0N/A
0N/A//---------------------------get_typeflow_type---------------------------------
0N/A// Import a type produced by ciTypeFlow.
0N/Aconst Type* Type::get_typeflow_type(ciType* type) {
0N/A switch (type->basic_type()) {
0N/A
0N/A case ciTypeFlow::StateVector::T_BOTTOM:
0N/A assert(type == ciTypeFlow::StateVector::bottom_type(), "");
0N/A return Type::BOTTOM;
0N/A
0N/A case ciTypeFlow::StateVector::T_TOP:
0N/A assert(type == ciTypeFlow::StateVector::top_type(), "");
0N/A return Type::TOP;
0N/A
0N/A case ciTypeFlow::StateVector::T_NULL:
0N/A assert(type == ciTypeFlow::StateVector::null_type(), "");
0N/A return TypePtr::NULL_PTR;
0N/A
0N/A case ciTypeFlow::StateVector::T_LONG2:
0N/A // The ciTypeFlow pass pushes a long, then the half.
0N/A // We do the same.
0N/A assert(type == ciTypeFlow::StateVector::long2_type(), "");
0N/A return TypeInt::TOP;
0N/A
0N/A case ciTypeFlow::StateVector::T_DOUBLE2:
0N/A // The ciTypeFlow pass pushes double, then the half.
0N/A // Our convention is the same.
0N/A assert(type == ciTypeFlow::StateVector::double2_type(), "");
0N/A return Type::TOP;
0N/A
0N/A case T_ADDRESS:
0N/A assert(type->is_return_address(), "");
0N/A return TypeRawPtr::make((address)(intptr_t)type->as_return_address()->bci());
0N/A
0N/A default:
0N/A // make sure we did not mix up the cases:
0N/A assert(type != ciTypeFlow::StateVector::bottom_type(), "");
0N/A assert(type != ciTypeFlow::StateVector::top_type(), "");
0N/A assert(type != ciTypeFlow::StateVector::null_type(), "");
0N/A assert(type != ciTypeFlow::StateVector::long2_type(), "");
0N/A assert(type != ciTypeFlow::StateVector::double2_type(), "");
0N/A assert(!type->is_return_address(), "");
0N/A
0N/A return Type::get_const_type(type);
0N/A }
0N/A}
0N/A
0N/A
0N/A//------------------------------make-------------------------------------------
0N/A// Create a simple Type, with default empty symbol sets. Then hashcons it
0N/A// and look for an existing copy in the type dictionary.
0N/Aconst Type *Type::make( enum TYPES t ) {
0N/A return (new Type(t))->hashcons();
0N/A}
223N/A
0N/A//------------------------------cmp--------------------------------------------
0N/Aint Type::cmp( const Type *const t1, const Type *const t2 ) {
0N/A if( t1->_base != t2->_base )
0N/A return 1; // Missed badly
0N/A assert(t1 != t2 || t1->eq(t2), "eq must be reflexive");
0N/A return !t1->eq(t2); // Return ZERO if equal
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/Aint Type::uhash( const Type *const t ) {
0N/A return t->hash();
0N/A}
0N/A
1540N/A#define SMALLINT ((juint)3) // a value too insignificant to consider widening
1540N/A
0N/A//--------------------------Initialize_shared----------------------------------
0N/Avoid Type::Initialize_shared(Compile* current) {
0N/A // This method does not need to be locked because the first system
0N/A // compilations (stub compilations) occur serially. If they are
0N/A // changed to proceed in parallel, then this section will need
0N/A // locking.
0N/A
0N/A Arena* save = current->type_arena();
3863N/A Arena* shared_type_arena = new (mtCompiler)Arena();
0N/A
0N/A current->set_type_arena(shared_type_arena);
0N/A _shared_type_dict =
0N/A new (shared_type_arena) Dict( (CmpKey)Type::cmp, (Hash)Type::uhash,
0N/A shared_type_arena, 128 );
0N/A current->set_type_dict(_shared_type_dict);
0N/A
0N/A // Make shared pre-built types.
0N/A CONTROL = make(Control); // Control only
0N/A TOP = make(Top); // No values in set
0N/A MEMORY = make(Memory); // Abstract store only
0N/A ABIO = make(Abio); // State-of-machine only
0N/A RETURN_ADDRESS=make(Return_Address);
0N/A FLOAT = make(FloatBot); // All floats
0N/A DOUBLE = make(DoubleBot); // All doubles
0N/A BOTTOM = make(Bottom); // Everything
0N/A HALF = make(Half); // Placeholder half of doublewide type
0N/A
0N/A TypeF::ZERO = TypeF::make(0.0); // Float 0 (positive zero)
0N/A TypeF::ONE = TypeF::make(1.0); // Float 1
0N/A
0N/A TypeD::ZERO = TypeD::make(0.0); // Double 0 (positive zero)
0N/A TypeD::ONE = TypeD::make(1.0); // Double 1
0N/A
0N/A TypeInt::MINUS_1 = TypeInt::make(-1); // -1
0N/A TypeInt::ZERO = TypeInt::make( 0); // 0
0N/A TypeInt::ONE = TypeInt::make( 1); // 1
0N/A TypeInt::BOOL = TypeInt::make(0,1, WidenMin); // 0 or 1, FALSE or TRUE.
0N/A TypeInt::CC = TypeInt::make(-1, 1, WidenMin); // -1, 0 or 1, condition codes
0N/A TypeInt::CC_LT = TypeInt::make(-1,-1, WidenMin); // == TypeInt::MINUS_1
0N/A TypeInt::CC_GT = TypeInt::make( 1, 1, WidenMin); // == TypeInt::ONE
0N/A TypeInt::CC_EQ = TypeInt::make( 0, 0, WidenMin); // == TypeInt::ZERO
0N/A TypeInt::CC_LE = TypeInt::make(-1, 0, WidenMin);
0N/A TypeInt::CC_GE = TypeInt::make( 0, 1, WidenMin); // == TypeInt::BOOL
0N/A TypeInt::BYTE = TypeInt::make(-128,127, WidenMin); // Bytes
624N/A TypeInt::UBYTE = TypeInt::make(0, 255, WidenMin); // Unsigned Bytes
0N/A TypeInt::CHAR = TypeInt::make(0,65535, WidenMin); // Java chars
0N/A TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts
0N/A TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values
0N/A TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values
0N/A TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers
0N/A TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range
0N/A // CmpL is overloaded both as the bytecode computation returning
0N/A // a trinary (-1,0,+1) integer result AND as an efficient long
0N/A // compare returning optimizer ideal-type flags.
0N/A assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" );
0N/A assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" );
0N/A assert( TypeInt::CC_EQ == TypeInt::ZERO, "types must match for CmpL to work" );
0N/A assert( TypeInt::CC_GE == TypeInt::BOOL, "types must match for CmpL to work" );
1540N/A assert( (juint)(TypeInt::CC->_hi - TypeInt::CC->_lo) <= SMALLINT, "CC is truly small");
0N/A
0N/A TypeLong::MINUS_1 = TypeLong::make(-1); // -1
0N/A TypeLong::ZERO = TypeLong::make( 0); // 0
0N/A TypeLong::ONE = TypeLong::make( 1); // 1
0N/A TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values
0N/A TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers
0N/A TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin);
0N/A TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin);
0N/A
0N/A const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
0N/A fboth[0] = Type::CONTROL;
0N/A fboth[1] = Type::CONTROL;
0N/A TypeTuple::IFBOTH = TypeTuple::make( 2, fboth );
0N/A
0N/A const Type **ffalse =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
0N/A ffalse[0] = Type::CONTROL;
0N/A ffalse[1] = Type::TOP;
0N/A TypeTuple::IFFALSE = TypeTuple::make( 2, ffalse );
0N/A
0N/A const Type **fneither =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
0N/A fneither[0] = Type::TOP;
0N/A fneither[1] = Type::TOP;
0N/A TypeTuple::IFNEITHER = TypeTuple::make( 2, fneither );
0N/A
0N/A const Type **ftrue =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
0N/A ftrue[0] = Type::TOP;
0N/A ftrue[1] = Type::CONTROL;
0N/A TypeTuple::IFTRUE = TypeTuple::make( 2, ftrue );
0N/A
0N/A const Type **floop =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
0N/A floop[0] = Type::CONTROL;
0N/A floop[1] = TypeInt::INT;
0N/A TypeTuple::LOOPBODY = TypeTuple::make( 2, floop );
0N/A
0N/A TypePtr::NULL_PTR= TypePtr::make( AnyPtr, TypePtr::Null, 0 );
0N/A TypePtr::NOTNULL = TypePtr::make( AnyPtr, TypePtr::NotNull, OffsetBot );
0N/A TypePtr::BOTTOM = TypePtr::make( AnyPtr, TypePtr::BotPTR, OffsetBot );
0N/A
0N/A TypeRawPtr::BOTTOM = TypeRawPtr::make( TypePtr::BotPTR );
0N/A TypeRawPtr::NOTNULL= TypeRawPtr::make( TypePtr::NotNull );
0N/A
0N/A const Type **fmembar = TypeTuple::fields(0);
0N/A TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar);
0N/A
0N/A const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
0N/A fsc[0] = TypeInt::CC;
0N/A fsc[1] = Type::MEMORY;
0N/A TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc);
0N/A
0N/A TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass());
0N/A TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass());
0N/A TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass());
0N/A TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
0N/A false, 0, oopDesc::mark_offset_in_bytes());
0N/A TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
0N/A false, 0, oopDesc::klass_offset_in_bytes());
992N/A TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot);
0N/A
113N/A TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR );
113N/A TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM );
113N/A
113N/A mreg2type[Op_Node] = Type::BOTTOM;
113N/A mreg2type[Op_Set ] = 0;
113N/A mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM;
113N/A mreg2type[Op_RegI] = TypeInt::INT;
113N/A mreg2type[Op_RegP] = TypePtr::BOTTOM;
113N/A mreg2type[Op_RegF] = Type::FLOAT;
113N/A mreg2type[Op_RegD] = Type::DOUBLE;
113N/A mreg2type[Op_RegL] = TypeLong::LONG;
113N/A mreg2type[Op_RegFlags] = TypeInt::CC;
113N/A
1681N/A TypeAryPtr::RANGE = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, arrayOopDesc::length_offset_in_bytes());
163N/A
163N/A TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot);
163N/A
163N/A#ifdef _LP64
163N/A if (UseCompressedOops) {
163N/A TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS;
163N/A } else
163N/A#endif
163N/A {
163N/A // There is no shared klass for Object[]. See note in TypeAryPtr::klass().
163N/A TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot);
163N/A }
0N/A TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Type::OffsetBot);
0N/A TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Type::OffsetBot);
0N/A TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Type::OffsetBot);
0N/A TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Type::OffsetBot);
0N/A TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Type::OffsetBot);
0N/A TypeAryPtr::FLOATS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT), true, Type::OffsetBot);
0N/A TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true, Type::OffsetBot);
0N/A
163N/A // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
163N/A TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
0N/A TypeAryPtr::_array_body_type[T_OBJECT] = TypeAryPtr::OOPS;
163N/A TypeAryPtr::_array_body_type[T_ARRAY] = TypeAryPtr::OOPS; // arrays are stored in oop arrays
0N/A TypeAryPtr::_array_body_type[T_BYTE] = TypeAryPtr::BYTES;
0N/A TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES; // boolean[] is a byte array
0N/A TypeAryPtr::_array_body_type[T_SHORT] = TypeAryPtr::SHORTS;
0N/A TypeAryPtr::_array_body_type[T_CHAR] = TypeAryPtr::CHARS;
0N/A TypeAryPtr::_array_body_type[T_INT] = TypeAryPtr::INTS;
0N/A TypeAryPtr::_array_body_type[T_LONG] = TypeAryPtr::LONGS;
0N/A TypeAryPtr::_array_body_type[T_FLOAT] = TypeAryPtr::FLOATS;
0N/A TypeAryPtr::_array_body_type[T_DOUBLE] = TypeAryPtr::DOUBLES;
0N/A
0N/A TypeKlassPtr::OBJECT = TypeKlassPtr::make( TypePtr::NotNull, current->env()->Object_klass(), 0 );
0N/A TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make( TypePtr::BotPTR, current->env()->Object_klass(), 0 );
0N/A
0N/A const Type **fi2c = TypeTuple::fields(2);
0N/A fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // methodOop
0N/A fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
0N/A TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);
0N/A
0N/A const Type **intpair = TypeTuple::fields(2);
0N/A intpair[0] = TypeInt::INT;
0N/A intpair[1] = TypeInt::INT;
0N/A TypeTuple::INT_PAIR = TypeTuple::make(2, intpair);
0N/A
0N/A const Type **longpair = TypeTuple::fields(2);
0N/A longpair[0] = TypeLong::LONG;
0N/A longpair[1] = TypeLong::LONG;
0N/A TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair);
0N/A
113N/A _const_basic_type[T_NARROWOOP] = TypeNarrowOop::BOTTOM;
0N/A _const_basic_type[T_BOOLEAN] = TypeInt::BOOL;
0N/A _const_basic_type[T_CHAR] = TypeInt::CHAR;
0N/A _const_basic_type[T_BYTE] = TypeInt::BYTE;
0N/A _const_basic_type[T_SHORT] = TypeInt::SHORT;
0N/A _const_basic_type[T_INT] = TypeInt::INT;
0N/A _const_basic_type[T_LONG] = TypeLong::LONG;
0N/A _const_basic_type[T_FLOAT] = Type::FLOAT;
0N/A _const_basic_type[T_DOUBLE] = Type::DOUBLE;
0N/A _const_basic_type[T_OBJECT] = TypeInstPtr::BOTTOM;
0N/A _const_basic_type[T_ARRAY] = TypeInstPtr::BOTTOM; // there is no separate bottom for arrays
0N/A _const_basic_type[T_VOID] = TypePtr::NULL_PTR; // reflection represents void this way
0N/A _const_basic_type[T_ADDRESS] = TypeRawPtr::BOTTOM; // both interpreter return addresses & random raw ptrs
0N/A _const_basic_type[T_CONFLICT]= Type::BOTTOM; // why not?
0N/A
113N/A _zero_type[T_NARROWOOP] = TypeNarrowOop::NULL_PTR;
0N/A _zero_type[T_BOOLEAN] = TypeInt::ZERO; // false == 0
0N/A _zero_type[T_CHAR] = TypeInt::ZERO; // '\0' == 0
0N/A _zero_type[T_BYTE] = TypeInt::ZERO; // 0x00 == 0
0N/A _zero_type[T_SHORT] = TypeInt::ZERO; // 0x0000 == 0
0N/A _zero_type[T_INT] = TypeInt::ZERO;
0N/A _zero_type[T_LONG] = TypeLong::ZERO;
0N/A _zero_type[T_FLOAT] = TypeF::ZERO;
0N/A _zero_type[T_DOUBLE] = TypeD::ZERO;
0N/A _zero_type[T_OBJECT] = TypePtr::NULL_PTR;
0N/A _zero_type[T_ARRAY] = TypePtr::NULL_PTR; // null array is null oop
0N/A _zero_type[T_ADDRESS] = TypePtr::NULL_PTR; // raw pointers use the same null
0N/A _zero_type[T_VOID] = Type::TOP; // the only void value is no value at all
0N/A
0N/A // get_zero_type() should not happen for T_CONFLICT
0N/A _zero_type[T_CONFLICT]= NULL;
0N/A
3845N/A // Vector predefined types, it needs initialized _const_basic_type[].
3845N/A if (Matcher::vector_size_supported(T_BYTE,4)) {
3845N/A TypeVect::VECTS = TypeVect::make(T_BYTE,4);
3845N/A }
3845N/A if (Matcher::vector_size_supported(T_FLOAT,2)) {
3845N/A TypeVect::VECTD = TypeVect::make(T_FLOAT,2);
3845N/A }
3845N/A if (Matcher::vector_size_supported(T_FLOAT,4)) {
3845N/A TypeVect::VECTX = TypeVect::make(T_FLOAT,4);
3845N/A }
3845N/A if (Matcher::vector_size_supported(T_FLOAT,8)) {
3845N/A TypeVect::VECTY = TypeVect::make(T_FLOAT,8);
3845N/A }
3845N/A mreg2type[Op_VecS] = TypeVect::VECTS;
3845N/A mreg2type[Op_VecD] = TypeVect::VECTD;
3845N/A mreg2type[Op_VecX] = TypeVect::VECTX;
3845N/A mreg2type[Op_VecY] = TypeVect::VECTY;
3845N/A
0N/A // Restore working type arena.
0N/A current->set_type_arena(save);
0N/A current->set_type_dict(NULL);
0N/A}
0N/A
0N/A//------------------------------Initialize-------------------------------------
0N/Avoid Type::Initialize(Compile* current) {
0N/A assert(current->type_arena() != NULL, "must have created type arena");
0N/A
0N/A if (_shared_type_dict == NULL) {
0N/A Initialize_shared(current);
0N/A }
0N/A
0N/A Arena* type_arena = current->type_arena();
0N/A
0N/A // Create the hash-cons'ing dictionary with top-level storage allocation
0N/A Dict *tdic = new (type_arena) Dict( (CmpKey)Type::cmp,(Hash)Type::uhash, type_arena, 128 );
0N/A current->set_type_dict(tdic);
0N/A
0N/A // Transfer the shared types.
0N/A DictI i(_shared_type_dict);
0N/A for( ; i.test(); ++i ) {
0N/A Type* t = (Type*)i._value;
0N/A tdic->Insert(t,t); // New Type, insert into Type table
0N/A }
113N/A
113N/A#ifdef ASSERT
113N/A verify_lastype();
113N/A#endif
0N/A}
0N/A
0N/A//------------------------------hashcons---------------------------------------
0N/A// Do the hash-cons trick. If the Type already exists in the type table,
0N/A// delete the current Type and return the existing Type. Otherwise stick the
0N/A// current Type in the Type table.
0N/Aconst Type *Type::hashcons(void) {
0N/A debug_only(base()); // Check the assertion in Type::base().
0N/A // Look up the Type in the Type dictionary
0N/A Dict *tdic = type_dict();
0N/A Type* old = (Type*)(tdic->Insert(this, this, false));
0N/A if( old ) { // Pre-existing Type?
0N/A if( old != this ) // Yes, this guy is not the pre-existing?
0N/A delete this; // Yes, Nuke this guy
0N/A assert( old->_dual, "" );
0N/A return old; // Return pre-existing
0N/A }
0N/A
0N/A // Every type has a dual (to make my lattice symmetric).
0N/A // Since we just discovered a new Type, compute its dual right now.
0N/A assert( !_dual, "" ); // No dual yet
0N/A _dual = xdual(); // Compute the dual
0N/A if( cmp(this,_dual)==0 ) { // Handle self-symmetric
0N/A _dual = this;
0N/A return this;
0N/A }
0N/A assert( !_dual->_dual, "" ); // No reverse dual yet
0N/A assert( !(*tdic)[_dual], "" ); // Dual not in type system either
0N/A // New Type, insert into Type table
0N/A tdic->Insert((void*)_dual,(void*)_dual);
0N/A ((Type*)_dual)->_dual = this; // Finish up being symmetric
0N/A#ifdef ASSERT
0N/A Type *dual_dual = (Type*)_dual->xdual();
0N/A assert( eq(dual_dual), "xdual(xdual()) should be identity" );
0N/A delete dual_dual;
0N/A#endif
0N/A return this; // Return new Type
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool Type::eq( const Type * ) const {
0N/A return true; // Nothing else can go wrong
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint Type::hash(void) const {
0N/A return _base;
0N/A}
0N/A
0N/A//------------------------------is_finite--------------------------------------
0N/A// Has a finite value
0N/Abool Type::is_finite() const {
0N/A return false;
0N/A}
0N/A
0N/A//------------------------------is_nan-----------------------------------------
0N/A// Is not a number (NaN)
0N/Abool Type::is_nan() const {
0N/A return false;
0N/A}
0N/A
820N/A//----------------------interface_vs_oop---------------------------------------
820N/A#ifdef ASSERT
820N/Abool Type::interface_vs_oop(const Type *t) const {
820N/A bool result = false;
820N/A
992N/A const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop
992N/A const TypePtr* t_ptr = t->make_ptr();
992N/A if( this_ptr == NULL || t_ptr == NULL )
992N/A return result;
992N/A
992N/A const TypeInstPtr* this_inst = this_ptr->isa_instptr();
992N/A const TypeInstPtr* t_inst = t_ptr->isa_instptr();
820N/A if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) {
820N/A bool this_interface = this_inst->klass()->is_interface();
820N/A bool t_interface = t_inst->klass()->is_interface();
820N/A result = this_interface ^ t_interface;
820N/A }
820N/A
820N/A return result;
820N/A}
820N/A#endif
820N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. NOT virtual. It enforces that meet is
0N/A// commutative and the lattice is symmetric.
0N/Aconst Type *Type::meet( const Type *t ) const {
113N/A if (isa_narrowoop() && t->isa_narrowoop()) {
221N/A const Type* result = make_ptr()->meet(t->make_ptr());
221N/A return result->make_narrowoop();
113N/A }
113N/A
0N/A const Type *mt = xmeet(t);
113N/A if (isa_narrowoop() || t->isa_narrowoop()) return mt;
0N/A#ifdef ASSERT
0N/A assert( mt == t->xmeet(this), "meet not commutative" );
0N/A const Type* dual_join = mt->_dual;
0N/A const Type *t2t = dual_join->xmeet(t->_dual);
0N/A const Type *t2this = dual_join->xmeet( _dual);
0N/A
0N/A // Interface meet Oop is Not Symmetric:
0N/A // Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull
0N/A // Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull
820N/A
820N/A if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != _dual) ) {
0N/A tty->print_cr("=== Meet Not Symmetric ===");
0N/A tty->print("t = "); t->dump(); tty->cr();
0N/A tty->print("this= "); dump(); tty->cr();
0N/A tty->print("mt=(t meet this)= "); mt->dump(); tty->cr();
0N/A
0N/A tty->print("t_dual= "); t->_dual->dump(); tty->cr();
0N/A tty->print("this_dual= "); _dual->dump(); tty->cr();
0N/A tty->print("mt_dual= "); mt->_dual->dump(); tty->cr();
0N/A
0N/A tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr();
0N/A tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr();
0N/A
0N/A fatal("meet not symmetric" );
0N/A }
0N/A#endif
0N/A return mt;
0N/A}
0N/A
0N/A//------------------------------xmeet------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *Type::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Meeting TOP with anything?
0N/A if( _base == Top ) return t;
0N/A
0N/A // Meeting BOTTOM with anything?
0N/A if( _base == Bottom ) return BOTTOM;
0N/A
0N/A // Current "this->_base" is one of: Bad, Multi, Control, Top,
0N/A // Abio, Abstore, Floatxxx, Doublexxx, Bottom, lastype.
0N/A switch (t->base()) { // Switch on original type
0N/A
0N/A // Cut in half the number of cases I must handle. Only need cases for when
0N/A // the given enum "t->type" is less than or equal to the local enum "type".
0N/A case FloatCon:
0N/A case DoubleCon:
0N/A case Int:
0N/A case Long:
0N/A return t->xmeet(this);
0N/A
0N/A case OopPtr:
0N/A return t->xmeet(this);
0N/A
0N/A case InstPtr:
0N/A return t->xmeet(this);
0N/A
0N/A case KlassPtr:
0N/A return t->xmeet(this);
0N/A
0N/A case AryPtr:
0N/A return t->xmeet(this);
0N/A
113N/A case NarrowOop:
113N/A return t->xmeet(this);
113N/A
0N/A case Bad: // Type check
0N/A default: // Bogus type not in lattice
0N/A typerr(t);
0N/A return Type::BOTTOM;
0N/A
0N/A case Bottom: // Ye Olde Default
0N/A return t;
0N/A
0N/A case FloatTop:
0N/A if( _base == FloatTop ) return this;
0N/A case FloatBot: // Float
0N/A if( _base == FloatBot || _base == FloatTop ) return FLOAT;
0N/A if( _base == DoubleTop || _base == DoubleBot ) return Type::BOTTOM;
0N/A typerr(t);
0N/A return Type::BOTTOM;
0N/A
0N/A case DoubleTop:
0N/A if( _base == DoubleTop ) return this;
0N/A case DoubleBot: // Double
0N/A if( _base == DoubleBot || _base == DoubleTop ) return DOUBLE;
0N/A if( _base == FloatTop || _base == FloatBot ) return Type::BOTTOM;
0N/A typerr(t);
0N/A return Type::BOTTOM;
0N/A
0N/A // These next few cases must match exactly or it is a compile-time error.
0N/A case Control: // Control of code
0N/A case Abio: // State of world outside of program
0N/A case Memory:
0N/A if( _base == t->_base ) return this;
0N/A typerr(t);
0N/A return Type::BOTTOM;
0N/A
0N/A case Top: // Top of the lattice
0N/A return this;
0N/A }
0N/A
0N/A // The type is unchanged
0N/A return this;
0N/A}
0N/A
0N/A//-----------------------------filter------------------------------------------
0N/Aconst Type *Type::filter( const Type *kills ) const {
0N/A const Type* ft = join(kills);
0N/A if (ft->empty())
0N/A return Type::TOP; // Canonical empty value
0N/A return ft;
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Compute dual right now.
0N/Aconst Type::TYPES Type::dual_type[Type::lastype] = {
0N/A Bad, // Bad
0N/A Control, // Control
0N/A Bottom, // Top
0N/A Bad, // Int - handled in v-call
0N/A Bad, // Long - handled in v-call
0N/A Half, // Half
113N/A Bad, // NarrowOop - handled in v-call
0N/A
0N/A Bad, // Tuple - handled in v-call
0N/A Bad, // Array - handled in v-call
3845N/A Bad, // VectorS - handled in v-call
3845N/A Bad, // VectorD - handled in v-call
3845N/A Bad, // VectorX - handled in v-call
3845N/A Bad, // VectorY - handled in v-call
0N/A
0N/A Bad, // AnyPtr - handled in v-call
0N/A Bad, // RawPtr - handled in v-call
0N/A Bad, // OopPtr - handled in v-call
0N/A Bad, // InstPtr - handled in v-call
0N/A Bad, // AryPtr - handled in v-call
0N/A Bad, // KlassPtr - handled in v-call
0N/A
0N/A Bad, // Function - handled in v-call
0N/A Abio, // Abio
0N/A Return_Address,// Return_Address
0N/A Memory, // Memory
0N/A FloatBot, // FloatTop
0N/A FloatCon, // FloatCon
0N/A FloatTop, // FloatBot
0N/A DoubleBot, // DoubleTop
0N/A DoubleCon, // DoubleCon
0N/A DoubleTop, // DoubleBot
0N/A Top // Bottom
0N/A};
0N/A
0N/Aconst Type *Type::xdual() const {
0N/A // Note: the base() accessor asserts the sanity of _base.
0N/A assert(dual_type[base()] != Bad, "implement with v-call");
0N/A return new Type(dual_type[_base]);
0N/A}
0N/A
0N/A//------------------------------has_memory-------------------------------------
0N/Abool Type::has_memory() const {
0N/A Type::TYPES tx = base();
0N/A if (tx == Memory) return true;
0N/A if (tx == Tuple) {
0N/A const TypeTuple *t = is_tuple();
0N/A for (uint i=0; i < t->cnt(); i++) {
0N/A tx = t->field_at(i)->base();
0N/A if (tx == Memory) return true;
0N/A }
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A#ifndef PRODUCT
0N/A//------------------------------dump2------------------------------------------
0N/Avoid Type::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A st->print(msg[_base]);
0N/A}
0N/A
0N/A//------------------------------dump-------------------------------------------
0N/Avoid Type::dump_on(outputStream *st) const {
0N/A ResourceMark rm;
0N/A Dict d(cmpkey,hashkey); // Stop recursive type dumping
0N/A dump2(d,1, st);
163N/A if (is_ptr_to_narrowoop()) {
113N/A st->print(" [narrow]");
113N/A }
0N/A}
0N/A
0N/A//------------------------------data-------------------------------------------
0N/Aconst char * const Type::msg[Type::lastype] = {
113N/A "bad","control","top","int:","long:","half", "narrowoop:",
3845N/A "tuple:", "array:", "vectors:", "vectord:", "vectorx:", "vectory:",
3845N/A "anyptr:", "rawptr:", "java:", "inst:", "aryptr:", "klass:",
0N/A "func", "abIO", "return_address", "memory",
0N/A "float_top", "ftcon:", "float",
0N/A "double_top", "dblcon:", "double",
0N/A "bottom"
0N/A};
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants (Ldi nodes). Singletons are integer, float or double constants.
0N/Abool Type::singleton(void) const {
0N/A return _base == Top || _base == Half;
0N/A}
0N/A
0N/A//------------------------------empty------------------------------------------
0N/A// TRUE if Type is a type with no values, FALSE otherwise.
0N/Abool Type::empty(void) const {
0N/A switch (_base) {
0N/A case DoubleTop:
0N/A case FloatTop:
0N/A case Top:
0N/A return true;
0N/A
0N/A case Half:
0N/A case Abio:
0N/A case Return_Address:
0N/A case Memory:
0N/A case Bottom:
0N/A case FloatBot:
0N/A case DoubleBot:
0N/A return false; // never a singleton, therefore never empty
0N/A }
0N/A
0N/A ShouldNotReachHere();
0N/A return false;
0N/A}
0N/A
0N/A//------------------------------dump_stats-------------------------------------
0N/A// Dump collected statistics to stderr
0N/A#ifndef PRODUCT
0N/Avoid Type::dump_stats() {
0N/A tty->print("Types made: %d\n", type_dict()->Size());
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------typerr-----------------------------------------
0N/Avoid Type::typerr( const Type *t ) const {
0N/A#ifndef PRODUCT
0N/A tty->print("\nError mixing types: ");
0N/A dump();
0N/A tty->print(" and ");
0N/A t->dump();
0N/A tty->print("\n");
0N/A#endif
0N/A ShouldNotReachHere();
0N/A}
0N/A
0N/A//------------------------------isa_oop_ptr------------------------------------
0N/A// Return true if type is an oop pointer type. False for raw pointers.
0N/Astatic char isa_oop_ptr_tbl[Type::lastype] = {
3845N/A 0,0,0,0,0,0,0/*narrowoop*/,0/*tuple*/, 0/*array*/, 0, 0, 0, 0/*vector*/,
0N/A 0/*anyptr*/,0/*rawptr*/,1/*OopPtr*/,1/*InstPtr*/,1/*AryPtr*/,1/*KlassPtr*/,
0N/A 0/*func*/,0,0/*return_address*/,0,
0N/A /*floats*/0,0,0, /*doubles*/0,0,0,
0N/A 0
0N/A};
0N/Abool Type::isa_oop_ptr() const {
0N/A return isa_oop_ptr_tbl[_base] != 0;
0N/A}
0N/A
0N/A//------------------------------dump_stats-------------------------------------
0N/A// // Check that arrays match type enum
0N/A#ifndef PRODUCT
0N/Avoid Type::verify_lastype() {
0N/A // Check that arrays match enumeration
0N/A assert( Type::dual_type [Type::lastype - 1] == Type::Top, "did not update array");
0N/A assert( strcmp(Type::msg [Type::lastype - 1],"bottom") == 0, "did not update array");
0N/A // assert( PhiNode::tbl [Type::lastype - 1] == NULL, "did not update array");
0N/A assert( Matcher::base2reg[Type::lastype - 1] == 0, "did not update array");
0N/A assert( isa_oop_ptr_tbl [Type::lastype - 1] == (char)0, "did not update array");
0N/A}
0N/A#endif
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst TypeF *TypeF::ZERO; // Floating point zero
0N/Aconst TypeF *TypeF::ONE; // Floating point one
0N/A
0N/A//------------------------------make-------------------------------------------
0N/A// Create a float constant
0N/Aconst TypeF *TypeF::make(float f) {
0N/A return (TypeF*)(new TypeF(f))->hashcons();
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeF::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is FloatCon
0N/A switch (t->base()) { // Switch on original type
0N/A case AnyPtr: // Mixing with oops happens when javac
0N/A case RawPtr: // reuses local variables
0N/A case OopPtr:
0N/A case InstPtr:
0N/A case KlassPtr:
0N/A case AryPtr:
293N/A case NarrowOop:
0N/A case Int:
0N/A case Long:
0N/A case DoubleTop:
0N/A case DoubleCon:
0N/A case DoubleBot:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A
0N/A case FloatBot:
0N/A return t;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case FloatCon: // Float-constant vs Float-constant?
0N/A if( jint_cast(_f) != jint_cast(t->getf()) ) // unequal constants?
0N/A // must compare bitwise as positive zero, negative zero and NaN have
0N/A // all the same representation in C++
0N/A return FLOAT; // Return generic float
0N/A // Equal constants
0N/A case Top:
0N/A case FloatTop:
0N/A break; // Return the float constant
0N/A }
0N/A return this; // Return the float constant
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: symmetric
0N/Aconst Type *TypeF::xdual() const {
0N/A return this;
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeF::eq( const Type *t ) const {
0N/A if( g_isnan(_f) ||
0N/A g_isnan(t->getf()) ) {
0N/A // One or both are NANs. If both are NANs return true, else false.
0N/A return (g_isnan(_f) && g_isnan(t->getf()));
0N/A }
0N/A if (_f == t->getf()) {
0N/A // (NaN is impossible at this point, since it is not equal even to itself)
0N/A if (_f == 0.0) {
0N/A // difference between positive and negative zero
0N/A if (jint_cast(_f) != jint_cast(t->getf())) return false;
0N/A }
0N/A return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeF::hash(void) const {
0N/A return *(int*)(&_f);
0N/A}
0N/A
0N/A//------------------------------is_finite--------------------------------------
0N/A// Has a finite value
0N/Abool TypeF::is_finite() const {
0N/A return g_isfinite(getf()) != 0;
0N/A}
0N/A
0N/A//------------------------------is_nan-----------------------------------------
0N/A// Is not a number (NaN)
0N/Abool TypeF::is_nan() const {
0N/A return g_isnan(getf()) != 0;
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A// Dump float constant Type
0N/A#ifndef PRODUCT
0N/Avoid TypeF::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A Type::dump2(d,depth, st);
0N/A st->print("%f", _f);
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants (Ldi nodes). Singletons are integer, float or double constants
0N/A// or a single symbol.
0N/Abool TypeF::singleton(void) const {
0N/A return true; // Always a singleton
0N/A}
0N/A
0N/Abool TypeF::empty(void) const {
0N/A return false; // always exactly a singleton
0N/A}
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst TypeD *TypeD::ZERO; // Floating point zero
0N/Aconst TypeD *TypeD::ONE; // Floating point one
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeD *TypeD::make(double d) {
0N/A return (TypeD*)(new TypeD(d))->hashcons();
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeD::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is DoubleCon
0N/A switch (t->base()) { // Switch on original type
0N/A case AnyPtr: // Mixing with oops happens when javac
0N/A case RawPtr: // reuses local variables
0N/A case OopPtr:
0N/A case InstPtr:
0N/A case KlassPtr:
0N/A case AryPtr:
183N/A case NarrowOop:
0N/A case Int:
0N/A case Long:
0N/A case FloatTop:
0N/A case FloatCon:
0N/A case FloatBot:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A
0N/A case DoubleBot:
0N/A return t;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case DoubleCon: // Double-constant vs Double-constant?
0N/A if( jlong_cast(_d) != jlong_cast(t->getd()) ) // unequal constants? (see comment in TypeF::xmeet)
0N/A return DOUBLE; // Return generic double
0N/A case Top:
0N/A case DoubleTop:
0N/A break;
0N/A }
0N/A return this; // Return the double constant
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: symmetric
0N/Aconst Type *TypeD::xdual() const {
0N/A return this;
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeD::eq( const Type *t ) const {
0N/A if( g_isnan(_d) ||
0N/A g_isnan(t->getd()) ) {
0N/A // One or both are NANs. If both are NANs return true, else false.
0N/A return (g_isnan(_d) && g_isnan(t->getd()));
0N/A }
0N/A if (_d == t->getd()) {
0N/A // (NaN is impossible at this point, since it is not equal even to itself)
0N/A if (_d == 0.0) {
0N/A // difference between positive and negative zero
0N/A if (jlong_cast(_d) != jlong_cast(t->getd())) return false;
0N/A }
0N/A return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeD::hash(void) const {
0N/A return *(int*)(&_d);
0N/A}
0N/A
0N/A//------------------------------is_finite--------------------------------------
0N/A// Has a finite value
0N/Abool TypeD::is_finite() const {
0N/A return g_isfinite(getd()) != 0;
0N/A}
0N/A
0N/A//------------------------------is_nan-----------------------------------------
0N/A// Is not a number (NaN)
0N/Abool TypeD::is_nan() const {
0N/A return g_isnan(getd()) != 0;
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A// Dump double constant Type
0N/A#ifndef PRODUCT
0N/Avoid TypeD::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A Type::dump2(d,depth,st);
0N/A st->print("%f", _d);
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants (Ldi nodes). Singletons are integer, float or double constants
0N/A// or a single symbol.
0N/Abool TypeD::singleton(void) const {
0N/A return true; // Always a singleton
0N/A}
0N/A
0N/Abool TypeD::empty(void) const {
0N/A return false; // always exactly a singleton
0N/A}
0N/A
0N/A//=============================================================================
0N/A// Convience common pre-built types.
0N/Aconst TypeInt *TypeInt::MINUS_1;// -1
0N/Aconst TypeInt *TypeInt::ZERO; // 0
0N/Aconst TypeInt *TypeInt::ONE; // 1
0N/Aconst TypeInt *TypeInt::BOOL; // 0 or 1, FALSE or TRUE.
0N/Aconst TypeInt *TypeInt::CC; // -1,0 or 1, condition codes
0N/Aconst TypeInt *TypeInt::CC_LT; // [-1] == MINUS_1
0N/Aconst TypeInt *TypeInt::CC_GT; // [1] == ONE
0N/Aconst TypeInt *TypeInt::CC_EQ; // [0] == ZERO
0N/Aconst TypeInt *TypeInt::CC_LE; // [-1,0]
0N/Aconst TypeInt *TypeInt::CC_GE; // [0,1] == BOOL (!)
0N/Aconst TypeInt *TypeInt::BYTE; // Bytes, -128 to 127
624N/Aconst TypeInt *TypeInt::UBYTE; // Unsigned Bytes, 0 to 255
0N/Aconst TypeInt *TypeInt::CHAR; // Java chars, 0-65535
0N/Aconst TypeInt *TypeInt::SHORT; // Java shorts, -32768-32767
0N/Aconst TypeInt *TypeInt::POS; // Positive 32-bit integers or zero
0N/Aconst TypeInt *TypeInt::POS1; // Positive 32-bit integers
0N/Aconst TypeInt *TypeInt::INT; // 32-bit integers
0N/Aconst TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint]
0N/A
0N/A//------------------------------TypeInt----------------------------------------
0N/ATypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) {
0N/A}
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeInt *TypeInt::make( jint lo ) {
0N/A return (TypeInt*)(new TypeInt(lo,lo,WidenMin))->hashcons();
0N/A}
0N/A
1540N/Astatic int normalize_int_widen( jint lo, jint hi, int w ) {
0N/A // Certain normalizations keep us sane when comparing types.
0N/A // The 'SMALLINT' covers constants and also CC and its relatives.
0N/A if (lo <= hi) {
1540N/A if ((juint)(hi - lo) <= SMALLINT) w = Type::WidenMin;
1540N/A if ((juint)(hi - lo) >= max_juint) w = Type::WidenMax; // TypeInt::INT
1540N/A } else {
1540N/A if ((juint)(lo - hi) <= SMALLINT) w = Type::WidenMin;
1540N/A if ((juint)(lo - hi) >= max_juint) w = Type::WidenMin; // dual TypeInt::INT
0N/A }
1540N/A return w;
1540N/A}
1540N/A
1540N/Aconst TypeInt *TypeInt::make( jint lo, jint hi, int w ) {
1540N/A w = normalize_int_widen(lo, hi, w);
0N/A return (TypeInt*)(new TypeInt(lo,hi,w))->hashcons();
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type representation object
0N/A// with reference count equal to the number of Types pointing at it.
0N/A// Caller should wrap a Types around it.
0N/Aconst Type *TypeInt::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type?
0N/A
0N/A // Currently "this->_base" is a TypeInt
0N/A switch (t->base()) { // Switch on original type
0N/A case AnyPtr: // Mixing with oops happens when javac
0N/A case RawPtr: // reuses local variables
0N/A case OopPtr:
0N/A case InstPtr:
0N/A case KlassPtr:
0N/A case AryPtr:
183N/A case NarrowOop:
0N/A case Long:
0N/A case FloatTop:
0N/A case FloatCon:
0N/A case FloatBot:
0N/A case DoubleTop:
0N/A case DoubleCon:
0N/A case DoubleBot:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A case Top: // No change
0N/A return this;
0N/A case Int: // Int vs Int?
0N/A break;
0N/A }
0N/A
0N/A // Expand covered set
0N/A const TypeInt *r = t->is_int();
1540N/A return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) );
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: reverse hi & lo; flip widen
0N/Aconst Type *TypeInt::xdual() const {
1540N/A int w = normalize_int_widen(_hi,_lo, WidenMax-_widen);
1540N/A return new TypeInt(_hi,_lo,w);
0N/A}
0N/A
0N/A//------------------------------widen------------------------------------------
0N/A// Only happens for optimistic top-down optimizations.
1009N/Aconst Type *TypeInt::widen( const Type *old, const Type* limit ) const {
0N/A // Coming from TOP or such; no widening
0N/A if( old->base() != Int ) return this;
0N/A const TypeInt *ot = old->is_int();
0N/A
0N/A // If new guy is equal to old guy, no widening
0N/A if( _lo == ot->_lo && _hi == ot->_hi )
0N/A return old;
0N/A
0N/A // If new guy contains old, then we widened
0N/A if( _lo <= ot->_lo && _hi >= ot->_hi ) {
0N/A // New contains old
0N/A // If new guy is already wider than old, no widening
0N/A if( _widen > ot->_widen ) return this;
0N/A // If old guy was a constant, do not bother
0N/A if (ot->_lo == ot->_hi) return this;
0N/A // Now widen new guy.
0N/A // Check for widening too far
0N/A if (_widen == WidenMax) {
1009N/A int max = max_jint;
1009N/A int min = min_jint;
1009N/A if (limit->isa_int()) {
1009N/A max = limit->is_int()->_hi;
1009N/A min = limit->is_int()->_lo;
1009N/A }
1009N/A if (min < _lo && _hi < max) {
0N/A // If neither endpoint is extremal yet, push out the endpoint
0N/A // which is closer to its respective limit.
0N/A if (_lo >= 0 || // easy common case
1009N/A (juint)(_lo - min) >= (juint)(max - _hi)) {
0N/A // Try to widen to an unsigned range type of 31 bits:
1009N/A return make(_lo, max, WidenMax);
0N/A } else {
1009N/A return make(min, _hi, WidenMax);
0N/A }
0N/A }
0N/A return TypeInt::INT;
0N/A }
0N/A // Returned widened new guy
0N/A return make(_lo,_hi,_widen+1);
0N/A }
0N/A
0N/A // If old guy contains new, then we probably widened too far & dropped to
0N/A // bottom. Return the wider fellow.
0N/A if ( ot->_lo <= _lo && ot->_hi >= _hi )
0N/A return old;
0N/A
0N/A //fatal("Integer value range is not subset");
0N/A //return this;
0N/A return TypeInt::INT;
0N/A}
0N/A
0N/A//------------------------------narrow---------------------------------------
0N/A// Only happens for pessimistic optimizations.
0N/Aconst Type *TypeInt::narrow( const Type *old ) const {
0N/A if (_lo >= _hi) return this; // already narrow enough
0N/A if (old == NULL) return this;
0N/A const TypeInt* ot = old->isa_int();
0N/A if (ot == NULL) return this;
0N/A jint olo = ot->_lo;
0N/A jint ohi = ot->_hi;
0N/A
0N/A // If new guy is equal to old guy, no narrowing
0N/A if (_lo == olo && _hi == ohi) return old;
0N/A
0N/A // If old guy was maximum range, allow the narrowing
0N/A if (olo == min_jint && ohi == max_jint) return this;
0N/A
0N/A if (_lo < olo || _hi > ohi)
0N/A return this; // doesn't narrow; pretty wierd
0N/A
0N/A // The new type narrows the old type, so look for a "death march".
0N/A // See comments on PhaseTransform::saturate.
0N/A juint nrange = _hi - _lo;
0N/A juint orange = ohi - olo;
0N/A if (nrange < max_juint - 1 && nrange > (orange >> 1) + (SMALLINT*2)) {
0N/A // Use the new type only if the range shrinks a lot.
0N/A // We do not want the optimizer computing 2^31 point by point.
0N/A return old;
0N/A }
0N/A
0N/A return this;
0N/A}
0N/A
0N/A//-----------------------------filter------------------------------------------
0N/Aconst Type *TypeInt::filter( const Type *kills ) const {
0N/A const TypeInt* ft = join(kills)->isa_int();
1540N/A if (ft == NULL || ft->empty())
0N/A return Type::TOP; // Canonical empty value
0N/A if (ft->_widen < this->_widen) {
0N/A // Do not allow the value of kill->_widen to affect the outcome.
0N/A // The widen bits must be allowed to run freely through the graph.
0N/A ft = TypeInt::make(ft->_lo, ft->_hi, this->_widen);
0N/A }
0N/A return ft;
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeInt::eq( const Type *t ) const {
0N/A const TypeInt *r = t->is_int(); // Handy access
0N/A return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen;
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeInt::hash(void) const {
0N/A return _lo+_hi+_widen+(int)Type::Int;
0N/A}
0N/A
0N/A//------------------------------is_finite--------------------------------------
0N/A// Has a finite value
0N/Abool TypeInt::is_finite() const {
0N/A return true;
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A// Dump TypeInt
0N/A#ifndef PRODUCT
0N/Astatic const char* intname(char* buf, jint n) {
0N/A if (n == min_jint)
0N/A return "min";
0N/A else if (n < min_jint + 10000)
0N/A sprintf(buf, "min+" INT32_FORMAT, n - min_jint);
0N/A else if (n == max_jint)
0N/A return "max";
0N/A else if (n > max_jint - 10000)
0N/A sprintf(buf, "max-" INT32_FORMAT, max_jint - n);
0N/A else
0N/A sprintf(buf, INT32_FORMAT, n);
0N/A return buf;
0N/A}
0N/A
0N/Avoid TypeInt::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A char buf[40], buf2[40];
0N/A if (_lo == min_jint && _hi == max_jint)
0N/A st->print("int");
0N/A else if (is_con())
0N/A st->print("int:%s", intname(buf, get_con()));
0N/A else if (_lo == BOOL->_lo && _hi == BOOL->_hi)
0N/A st->print("bool");
0N/A else if (_lo == BYTE->_lo && _hi == BYTE->_hi)
0N/A st->print("byte");
0N/A else if (_lo == CHAR->_lo && _hi == CHAR->_hi)
0N/A st->print("char");
0N/A else if (_lo == SHORT->_lo && _hi == SHORT->_hi)
0N/A st->print("short");
0N/A else if (_hi == max_jint)
0N/A st->print("int:>=%s", intname(buf, _lo));
0N/A else if (_lo == min_jint)
0N/A st->print("int:<=%s", intname(buf, _hi));
0N/A else
0N/A st->print("int:%s..%s", intname(buf, _lo), intname(buf2, _hi));
0N/A
0N/A if (_widen != 0 && this != TypeInt::INT)
0N/A st->print(":%.*s", _widen, "wwww");
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants.
0N/Abool TypeInt::singleton(void) const {
0N/A return _lo >= _hi;
0N/A}
0N/A
0N/Abool TypeInt::empty(void) const {
0N/A return _lo > _hi;
0N/A}
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst TypeLong *TypeLong::MINUS_1;// -1
0N/Aconst TypeLong *TypeLong::ZERO; // 0
0N/Aconst TypeLong *TypeLong::ONE; // 1
0N/Aconst TypeLong *TypeLong::POS; // >=0
0N/Aconst TypeLong *TypeLong::LONG; // 64-bit integers
0N/Aconst TypeLong *TypeLong::INT; // 32-bit subrange
0N/Aconst TypeLong *TypeLong::UINT; // 32-bit unsigned subrange
0N/A
0N/A//------------------------------TypeLong---------------------------------------
0N/ATypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) {
0N/A}
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeLong *TypeLong::make( jlong lo ) {
0N/A return (TypeLong*)(new TypeLong(lo,lo,WidenMin))->hashcons();
0N/A}
0N/A
1540N/Astatic int normalize_long_widen( jlong lo, jlong hi, int w ) {
0N/A // Certain normalizations keep us sane when comparing types.
1540N/A // The 'SMALLINT' covers constants.
0N/A if (lo <= hi) {
1540N/A if ((julong)(hi - lo) <= SMALLINT) w = Type::WidenMin;
1540N/A if ((julong)(hi - lo) >= max_julong) w = Type::WidenMax; // TypeLong::LONG
1540N/A } else {
1540N/A if ((julong)(lo - hi) <= SMALLINT) w = Type::WidenMin;
1540N/A if ((julong)(lo - hi) >= max_julong) w = Type::WidenMin; // dual TypeLong::LONG
0N/A }
1540N/A return w;
1540N/A}
1540N/A
1540N/Aconst TypeLong *TypeLong::make( jlong lo, jlong hi, int w ) {
1540N/A w = normalize_long_widen(lo, hi, w);
0N/A return (TypeLong*)(new TypeLong(lo,hi,w))->hashcons();
0N/A}
0N/A
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type representation object
0N/A// with reference count equal to the number of Types pointing at it.
0N/A// Caller should wrap a Types around it.
0N/Aconst Type *TypeLong::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type?
0N/A
0N/A // Currently "this->_base" is a TypeLong
0N/A switch (t->base()) { // Switch on original type
0N/A case AnyPtr: // Mixing with oops happens when javac
0N/A case RawPtr: // reuses local variables
0N/A case OopPtr:
0N/A case InstPtr:
0N/A case KlassPtr:
0N/A case AryPtr:
183N/A case NarrowOop:
0N/A case Int:
0N/A case FloatTop:
0N/A case FloatCon:
0N/A case FloatBot:
0N/A case DoubleTop:
0N/A case DoubleCon:
0N/A case DoubleBot:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A case Top: // No change
0N/A return this;
0N/A case Long: // Long vs Long?
0N/A break;
0N/A }
0N/A
0N/A // Expand covered set
0N/A const TypeLong *r = t->is_long(); // Turn into a TypeLong
1540N/A return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) );
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: reverse hi & lo; flip widen
0N/Aconst Type *TypeLong::xdual() const {
1540N/A int w = normalize_long_widen(_hi,_lo, WidenMax-_widen);
1540N/A return new TypeLong(_hi,_lo,w);
0N/A}
0N/A
0N/A//------------------------------widen------------------------------------------
0N/A// Only happens for optimistic top-down optimizations.
1009N/Aconst Type *TypeLong::widen( const Type *old, const Type* limit ) const {
0N/A // Coming from TOP or such; no widening
0N/A if( old->base() != Long ) return this;
0N/A const TypeLong *ot = old->is_long();
0N/A
0N/A // If new guy is equal to old guy, no widening
0N/A if( _lo == ot->_lo && _hi == ot->_hi )
0N/A return old;
0N/A
0N/A // If new guy contains old, then we widened
0N/A if( _lo <= ot->_lo && _hi >= ot->_hi ) {
0N/A // New contains old
0N/A // If new guy is already wider than old, no widening
0N/A if( _widen > ot->_widen ) return this;
0N/A // If old guy was a constant, do not bother
0N/A if (ot->_lo == ot->_hi) return this;
0N/A // Now widen new guy.
0N/A // Check for widening too far
0N/A if (_widen == WidenMax) {
1009N/A jlong max = max_jlong;
1009N/A jlong min = min_jlong;
1009N/A if (limit->isa_long()) {
1009N/A max = limit->is_long()->_hi;
1009N/A min = limit->is_long()->_lo;
1009N/A }
1009N/A if (min < _lo && _hi < max) {
0N/A // If neither endpoint is extremal yet, push out the endpoint
0N/A // which is closer to its respective limit.
0N/A if (_lo >= 0 || // easy common case
1009N/A (julong)(_lo - min) >= (julong)(max - _hi)) {
0N/A // Try to widen to an unsigned range type of 32/63 bits:
1009N/A if (max >= max_juint && _hi < max_juint)
0N/A return make(_lo, max_juint, WidenMax);
0N/A else
1009N/A return make(_lo, max, WidenMax);
0N/A } else {
1009N/A return make(min, _hi, WidenMax);
0N/A }
0N/A }
0N/A return TypeLong::LONG;
0N/A }
0N/A // Returned widened new guy
0N/A return make(_lo,_hi,_widen+1);
0N/A }
0N/A
0N/A // If old guy contains new, then we probably widened too far & dropped to
0N/A // bottom. Return the wider fellow.
0N/A if ( ot->_lo <= _lo && ot->_hi >= _hi )
0N/A return old;
0N/A
0N/A // fatal("Long value range is not subset");
0N/A // return this;
0N/A return TypeLong::LONG;
0N/A}
0N/A
0N/A//------------------------------narrow----------------------------------------
0N/A// Only happens for pessimistic optimizations.
0N/Aconst Type *TypeLong::narrow( const Type *old ) const {
0N/A if (_lo >= _hi) return this; // already narrow enough
0N/A if (old == NULL) return this;
0N/A const TypeLong* ot = old->isa_long();
0N/A if (ot == NULL) return this;
0N/A jlong olo = ot->_lo;
0N/A jlong ohi = ot->_hi;
0N/A
0N/A // If new guy is equal to old guy, no narrowing
0N/A if (_lo == olo && _hi == ohi) return old;
0N/A
0N/A // If old guy was maximum range, allow the narrowing
0N/A if (olo == min_jlong && ohi == max_jlong) return this;
0N/A
0N/A if (_lo < olo || _hi > ohi)
0N/A return this; // doesn't narrow; pretty wierd
0N/A
0N/A // The new type narrows the old type, so look for a "death march".
0N/A // See comments on PhaseTransform::saturate.
0N/A julong nrange = _hi - _lo;
0N/A julong orange = ohi - olo;
0N/A if (nrange < max_julong - 1 && nrange > (orange >> 1) + (SMALLINT*2)) {
0N/A // Use the new type only if the range shrinks a lot.
0N/A // We do not want the optimizer computing 2^31 point by point.
0N/A return old;
0N/A }
0N/A
0N/A return this;
0N/A}
0N/A
0N/A//-----------------------------filter------------------------------------------
0N/Aconst Type *TypeLong::filter( const Type *kills ) const {
0N/A const TypeLong* ft = join(kills)->isa_long();
1540N/A if (ft == NULL || ft->empty())
0N/A return Type::TOP; // Canonical empty value
0N/A if (ft->_widen < this->_widen) {
0N/A // Do not allow the value of kill->_widen to affect the outcome.
0N/A // The widen bits must be allowed to run freely through the graph.
0N/A ft = TypeLong::make(ft->_lo, ft->_hi, this->_widen);
0N/A }
0N/A return ft;
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeLong::eq( const Type *t ) const {
0N/A const TypeLong *r = t->is_long(); // Handy access
0N/A return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen;
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeLong::hash(void) const {
0N/A return (int)(_lo+_hi+_widen+(int)Type::Long);
0N/A}
0N/A
0N/A//------------------------------is_finite--------------------------------------
0N/A// Has a finite value
0N/Abool TypeLong::is_finite() const {
0N/A return true;
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A// Dump TypeLong
0N/A#ifndef PRODUCT
0N/Astatic const char* longnamenear(jlong x, const char* xname, char* buf, jlong n) {
0N/A if (n > x) {
0N/A if (n >= x + 10000) return NULL;
0N/A sprintf(buf, "%s+" INT64_FORMAT, xname, n - x);
0N/A } else if (n < x) {
0N/A if (n <= x - 10000) return NULL;
0N/A sprintf(buf, "%s-" INT64_FORMAT, xname, x - n);
0N/A } else {
0N/A return xname;
0N/A }
0N/A return buf;
0N/A}
0N/A
0N/Astatic const char* longname(char* buf, jlong n) {
0N/A const char* str;
0N/A if (n == min_jlong)
0N/A return "min";
0N/A else if (n < min_jlong + 10000)
0N/A sprintf(buf, "min+" INT64_FORMAT, n - min_jlong);
0N/A else if (n == max_jlong)
0N/A return "max";
0N/A else if (n > max_jlong - 10000)
0N/A sprintf(buf, "max-" INT64_FORMAT, max_jlong - n);
0N/A else if ((str = longnamenear(max_juint, "maxuint", buf, n)) != NULL)
0N/A return str;
0N/A else if ((str = longnamenear(max_jint, "maxint", buf, n)) != NULL)
0N/A return str;
0N/A else if ((str = longnamenear(min_jint, "minint", buf, n)) != NULL)
0N/A return str;
0N/A else
0N/A sprintf(buf, INT64_FORMAT, n);
0N/A return buf;
0N/A}
0N/A
0N/Avoid TypeLong::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A char buf[80], buf2[80];
0N/A if (_lo == min_jlong && _hi == max_jlong)
0N/A st->print("long");
0N/A else if (is_con())
0N/A st->print("long:%s", longname(buf, get_con()));
0N/A else if (_hi == max_jlong)
0N/A st->print("long:>=%s", longname(buf, _lo));
0N/A else if (_lo == min_jlong)
0N/A st->print("long:<=%s", longname(buf, _hi));
0N/A else
0N/A st->print("long:%s..%s", longname(buf, _lo), longname(buf2, _hi));
0N/A
0N/A if (_widen != 0 && this != TypeLong::LONG)
0N/A st->print(":%.*s", _widen, "wwww");
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants
0N/Abool TypeLong::singleton(void) const {
0N/A return _lo >= _hi;
0N/A}
0N/A
0N/Abool TypeLong::empty(void) const {
0N/A return _lo > _hi;
0N/A}
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst TypeTuple *TypeTuple::IFBOTH; // Return both arms of IF as reachable
0N/Aconst TypeTuple *TypeTuple::IFFALSE;
0N/Aconst TypeTuple *TypeTuple::IFTRUE;
0N/Aconst TypeTuple *TypeTuple::IFNEITHER;
0N/Aconst TypeTuple *TypeTuple::LOOPBODY;
0N/Aconst TypeTuple *TypeTuple::MEMBAR;
0N/Aconst TypeTuple *TypeTuple::STORECONDITIONAL;
0N/Aconst TypeTuple *TypeTuple::START_I2C;
0N/Aconst TypeTuple *TypeTuple::INT_PAIR;
0N/Aconst TypeTuple *TypeTuple::LONG_PAIR;
0N/A
0N/A
0N/A//------------------------------make-------------------------------------------
0N/A// Make a TypeTuple from the range of a method signature
0N/Aconst TypeTuple *TypeTuple::make_range(ciSignature* sig) {
0N/A ciType* return_type = sig->return_type();
0N/A uint total_fields = TypeFunc::Parms + return_type->size();
0N/A const Type **field_array = fields(total_fields);
0N/A switch (return_type->basic_type()) {
0N/A case T_LONG:
0N/A field_array[TypeFunc::Parms] = TypeLong::LONG;
0N/A field_array[TypeFunc::Parms+1] = Type::HALF;
0N/A break;
0N/A case T_DOUBLE:
0N/A field_array[TypeFunc::Parms] = Type::DOUBLE;
0N/A field_array[TypeFunc::Parms+1] = Type::HALF;
0N/A break;
0N/A case T_OBJECT:
0N/A case T_ARRAY:
0N/A case T_BOOLEAN:
0N/A case T_CHAR:
0N/A case T_FLOAT:
0N/A case T_BYTE:
0N/A case T_SHORT:
0N/A case T_INT:
0N/A field_array[TypeFunc::Parms] = get_const_type(return_type);
0N/A break;
0N/A case T_VOID:
0N/A break;
0N/A default:
0N/A ShouldNotReachHere();
0N/A }
0N/A return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons();
0N/A}
0N/A
0N/A// Make a TypeTuple from the domain of a method signature
0N/Aconst TypeTuple *TypeTuple::make_domain(ciInstanceKlass* recv, ciSignature* sig) {
0N/A uint total_fields = TypeFunc::Parms + sig->size();
0N/A
0N/A uint pos = TypeFunc::Parms;
0N/A const Type **field_array;
0N/A if (recv != NULL) {
0N/A total_fields++;
0N/A field_array = fields(total_fields);
0N/A // Use get_const_type here because it respects UseUniqueSubclasses:
0N/A field_array[pos++] = get_const_type(recv)->join(TypePtr::NOTNULL);
0N/A } else {
0N/A field_array = fields(total_fields);
0N/A }
0N/A
0N/A int i = 0;
0N/A while (pos < total_fields) {
0N/A ciType* type = sig->type_at(i);
0N/A
0N/A switch (type->basic_type()) {
0N/A case T_LONG:
0N/A field_array[pos++] = TypeLong::LONG;
0N/A field_array[pos++] = Type::HALF;
0N/A break;
0N/A case T_DOUBLE:
0N/A field_array[pos++] = Type::DOUBLE;
0N/A field_array[pos++] = Type::HALF;
0N/A break;
0N/A case T_OBJECT:
0N/A case T_ARRAY:
0N/A case T_BOOLEAN:
0N/A case T_CHAR:
0N/A case T_FLOAT:
0N/A case T_BYTE:
0N/A case T_SHORT:
0N/A case T_INT:
0N/A field_array[pos++] = get_const_type(type);
0N/A break;
0N/A default:
0N/A ShouldNotReachHere();
0N/A }
0N/A i++;
0N/A }
0N/A return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons();
0N/A}
0N/A
0N/Aconst TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) {
0N/A return (TypeTuple*)(new TypeTuple(cnt,fields))->hashcons();
0N/A}
0N/A
0N/A//------------------------------fields-----------------------------------------
0N/A// Subroutine call type with space allocated for argument types
0N/Aconst Type **TypeTuple::fields( uint arg_cnt ) {
0N/A const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms+arg_cnt)*sizeof(Type*) ));
0N/A flds[TypeFunc::Control ] = Type::CONTROL;
0N/A flds[TypeFunc::I_O ] = Type::ABIO;
0N/A flds[TypeFunc::Memory ] = Type::MEMORY;
0N/A flds[TypeFunc::FramePtr ] = TypeRawPtr::BOTTOM;
0N/A flds[TypeFunc::ReturnAdr] = Type::RETURN_ADDRESS;
0N/A
0N/A return flds;
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeTuple::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is Tuple
0N/A switch (t->base()) { // switch on original type
0N/A
0N/A case Bottom: // Ye Olde Default
0N/A return t;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case Tuple: { // Meeting 2 signatures?
0N/A const TypeTuple *x = t->is_tuple();
0N/A assert( _cnt == x->_cnt, "" );
0N/A const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) ));
0N/A for( uint i=0; i<_cnt; i++ )
0N/A fields[i] = field_at(i)->xmeet( x->field_at(i) );
0N/A return TypeTuple::make(_cnt,fields);
0N/A }
0N/A case Top:
0N/A break;
0N/A }
0N/A return this; // Return the double constant
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: compute field-by-field dual
0N/Aconst Type *TypeTuple::xdual() const {
0N/A const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) ));
0N/A for( uint i=0; i<_cnt; i++ )
0N/A fields[i] = _fields[i]->dual();
0N/A return new TypeTuple(_cnt,fields);
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeTuple::eq( const Type *t ) const {
0N/A const TypeTuple *s = (const TypeTuple *)t;
0N/A if (_cnt != s->_cnt) return false; // Unequal field counts
0N/A for (uint i = 0; i < _cnt; i++)
0N/A if (field_at(i) != s->field_at(i)) // POINTER COMPARE! NO RECURSION!
0N/A return false; // Missed
0N/A return true;
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeTuple::hash(void) const {
0N/A intptr_t sum = _cnt;
0N/A for( uint i=0; i<_cnt; i++ )
0N/A sum += (intptr_t)_fields[i]; // Hash on pointers directly
0N/A return sum;
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A// Dump signature Type
0N/A#ifndef PRODUCT
0N/Avoid TypeTuple::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A st->print("{");
0N/A if( !depth || d[this] ) { // Check for recursive print
0N/A st->print("...}");
0N/A return;
0N/A }
0N/A d.Insert((void*)this, (void*)this); // Stop recursion
0N/A if( _cnt ) {
0N/A uint i;
0N/A for( i=0; i<_cnt-1; i++ ) {
0N/A st->print("%d:", i);
0N/A _fields[i]->dump2(d, depth-1, st);
0N/A st->print(", ");
0N/A }
0N/A st->print("%d:", i);
0N/A _fields[i]->dump2(d, depth-1, st);
0N/A }
0N/A st->print("}");
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants (Ldi nodes). Singletons are integer, float or double constants
0N/A// or a single symbol.
0N/Abool TypeTuple::singleton(void) const {
0N/A return false; // Never a singleton
0N/A}
0N/A
0N/Abool TypeTuple::empty(void) const {
0N/A for( uint i=0; i<_cnt; i++ ) {
0N/A if (_fields[i]->empty()) return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/A
0N/Ainline const TypeInt* normalize_array_size(const TypeInt* size) {
0N/A // Certain normalizations keep us sane when comparing types.
0N/A // We do not want arrayOop variables to differ only by the wideness
0N/A // of their index types. Pick minimum wideness, since that is the
0N/A // forced wideness of small ranges anyway.
0N/A if (size->_widen != Type::WidenMin)
0N/A return TypeInt::make(size->_lo, size->_hi, Type::WidenMin);
0N/A else
0N/A return size;
0N/A}
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeAry *TypeAry::make( const Type *elem, const TypeInt *size) {
113N/A if (UseCompressedOops && elem->isa_oopptr()) {
221N/A elem = elem->make_narrowoop();
113N/A }
0N/A size = normalize_array_size(size);
0N/A return (TypeAry*)(new TypeAry(elem,size))->hashcons();
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeAry::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is Ary
0N/A switch (t->base()) { // switch on original type
0N/A
0N/A case Bottom: // Ye Olde Default
0N/A return t;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case Array: { // Meeting 2 arrays?
0N/A const TypeAry *a = t->is_ary();
0N/A return TypeAry::make(_elem->meet(a->_elem),
0N/A _size->xmeet(a->_size)->is_int());
0N/A }
0N/A case Top:
0N/A break;
0N/A }
0N/A return this; // Return the double constant
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: compute field-by-field dual
0N/Aconst Type *TypeAry::xdual() const {
0N/A const TypeInt* size_dual = _size->dual()->is_int();
0N/A size_dual = normalize_array_size(size_dual);
0N/A return new TypeAry( _elem->dual(), size_dual);
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeAry::eq( const Type *t ) const {
0N/A const TypeAry *a = (const TypeAry*)t;
0N/A return _elem == a->_elem &&
0N/A _size == a->_size;
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeAry::hash(void) const {
0N/A return (intptr_t)_elem + (intptr_t)_size;
0N/A}
0N/A
820N/A//----------------------interface_vs_oop---------------------------------------
820N/A#ifdef ASSERT
820N/Abool TypeAry::interface_vs_oop(const Type *t) const {
820N/A const TypeAry* t_ary = t->is_ary();
820N/A if (t_ary) {
820N/A return _elem->interface_vs_oop(t_ary->_elem);
820N/A }
820N/A return false;
820N/A}
820N/A#endif
820N/A
0N/A//------------------------------dump2------------------------------------------
0N/A#ifndef PRODUCT
0N/Avoid TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A _elem->dump2(d, depth, st);
0N/A st->print("[");
0N/A _size->dump2(d, depth, st);
0N/A st->print("]");
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants (Ldi nodes). Singletons are integer, float or double constants
0N/A// or a single symbol.
0N/Abool TypeAry::singleton(void) const {
0N/A return false; // Never a singleton
0N/A}
0N/A
0N/Abool TypeAry::empty(void) const {
0N/A return _elem->empty() || _size->empty();
0N/A}
0N/A
0N/A//--------------------------ary_must_be_exact----------------------------------
0N/Abool TypeAry::ary_must_be_exact() const {
0N/A if (!UseExactTypes) return false;
0N/A // This logic looks at the element type of an array, and returns true
0N/A // if the element type is either a primitive or a final instance class.
0N/A // In such cases, an array built on this ary must have no subclasses.
0N/A if (_elem == BOTTOM) return false; // general array not exact
0N/A if (_elem == TOP ) return false; // inverted general array not exact
113N/A const TypeOopPtr* toop = NULL;
221N/A if (UseCompressedOops && _elem->isa_narrowoop()) {
221N/A toop = _elem->make_ptr()->isa_oopptr();
113N/A } else {
113N/A toop = _elem->isa_oopptr();
113N/A }
0N/A if (!toop) return true; // a primitive type, like int
0N/A ciKlass* tklass = toop->klass();
0N/A if (tklass == NULL) return false; // unloaded class
0N/A if (!tklass->is_loaded()) return false; // unloaded class
113N/A const TypeInstPtr* tinst;
113N/A if (_elem->isa_narrowoop())
221N/A tinst = _elem->make_ptr()->isa_instptr();
113N/A else
113N/A tinst = _elem->isa_instptr();
221N/A if (tinst)
221N/A return tklass->as_instance_klass()->is_final();
113N/A const TypeAryPtr* tap;
113N/A if (_elem->isa_narrowoop())
221N/A tap = _elem->make_ptr()->isa_aryptr();
113N/A else
113N/A tap = _elem->isa_aryptr();
221N/A if (tap)
221N/A return tap->ary()->ary_must_be_exact();
0N/A return false;
0N/A}
0N/A
3845N/A//==============================TypeVect=======================================
3845N/A// Convenience common pre-built types.
3845N/Aconst TypeVect *TypeVect::VECTS = NULL; // 32-bit vectors
3845N/Aconst TypeVect *TypeVect::VECTD = NULL; // 64-bit vectors
3845N/Aconst TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
3845N/Aconst TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
3845N/A
3845N/A//------------------------------make-------------------------------------------
3845N/Aconst TypeVect* TypeVect::make(const Type *elem, uint length) {
3845N/A BasicType elem_bt = elem->array_element_basic_type();
3845N/A assert(is_java_primitive(elem_bt), "only primitive types in vector");
3845N/A assert(length > 1 && is_power_of_2(length), "vector length is power of 2");
3845N/A assert(Matcher::vector_size_supported(elem_bt, length), "length in range");
3845N/A int size = length * type2aelembytes(elem_bt);
3845N/A switch (Matcher::vector_ideal_reg(size)) {
3845N/A case Op_VecS:
3845N/A return (TypeVect*)(new TypeVectS(elem, length))->hashcons();
3845N/A case Op_VecD:
3845N/A case Op_RegD:
3845N/A return (TypeVect*)(new TypeVectD(elem, length))->hashcons();
3845N/A case Op_VecX:
3845N/A return (TypeVect*)(new TypeVectX(elem, length))->hashcons();
3845N/A case Op_VecY:
3845N/A return (TypeVect*)(new TypeVectY(elem, length))->hashcons();
3845N/A }
3845N/A ShouldNotReachHere();
3845N/A return NULL;
3845N/A}
3845N/A
3845N/A//------------------------------meet-------------------------------------------
3845N/A// Compute the MEET of two types. It returns a new Type object.
3845N/Aconst Type *TypeVect::xmeet( const Type *t ) const {
3845N/A // Perform a fast test for common case; meeting the same types together.
3845N/A if( this == t ) return this; // Meeting same type-rep?
3845N/A
3845N/A // Current "this->_base" is Vector
3845N/A switch (t->base()) { // switch on original type
3845N/A
3845N/A case Bottom: // Ye Olde Default
3845N/A return t;
3845N/A
3845N/A default: // All else is a mistake
3845N/A typerr(t);
3845N/A
3845N/A case VectorS:
3845N/A case VectorD:
3845N/A case VectorX:
3845N/A case VectorY: { // Meeting 2 vectors?
3845N/A const TypeVect* v = t->is_vect();
3845N/A assert( base() == v->base(), "");
3845N/A assert(length() == v->length(), "");
3845N/A assert(element_basic_type() == v->element_basic_type(), "");
3845N/A return TypeVect::make(_elem->xmeet(v->_elem), _length);
3845N/A }
3845N/A case Top:
3845N/A break;
3845N/A }
3845N/A return this;
3845N/A}
3845N/A
3845N/A//------------------------------xdual------------------------------------------
3845N/A// Dual: compute field-by-field dual
3845N/Aconst Type *TypeVect::xdual() const {
3845N/A return new TypeVect(base(), _elem->dual(), _length);
3845N/A}
3845N/A
3845N/A//------------------------------eq---------------------------------------------
3845N/A// Structural equality check for Type representations
3845N/Abool TypeVect::eq(const Type *t) const {
3845N/A const TypeVect *v = t->is_vect();
3845N/A return (_elem == v->_elem) && (_length == v->_length);
3845N/A}
3845N/A
3845N/A//------------------------------hash-------------------------------------------
3845N/A// Type-specific hashing function.
3845N/Aint TypeVect::hash(void) const {
3845N/A return (intptr_t)_elem + (intptr_t)_length;
3845N/A}
3845N/A
3845N/A//------------------------------singleton--------------------------------------
3845N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
3845N/A// constants (Ldi nodes). Vector is singleton if all elements are the same
3845N/A// constant value (when vector is created with Replicate code).
3845N/Abool TypeVect::singleton(void) const {
3845N/A// There is no Con node for vectors yet.
3845N/A// return _elem->singleton();
3845N/A return false;
3845N/A}
3845N/A
3845N/Abool TypeVect::empty(void) const {
3845N/A return _elem->empty();
3845N/A}
3845N/A
3845N/A//------------------------------dump2------------------------------------------
3845N/A#ifndef PRODUCT
3845N/Avoid TypeVect::dump2(Dict &d, uint depth, outputStream *st) const {
3845N/A switch (base()) {
3845N/A case VectorS:
3845N/A st->print("vectors["); break;
3845N/A case VectorD:
3845N/A st->print("vectord["); break;
3845N/A case VectorX:
3845N/A st->print("vectorx["); break;
3845N/A case VectorY:
3845N/A st->print("vectory["); break;
3845N/A default:
3845N/A ShouldNotReachHere();
3845N/A }
3845N/A st->print("%d]:{", _length);
3845N/A _elem->dump2(d, depth, st);
3845N/A st->print("}");
3845N/A}
3845N/A#endif
3845N/A
3845N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst TypePtr *TypePtr::NULL_PTR;
0N/Aconst TypePtr *TypePtr::NOTNULL;
0N/Aconst TypePtr *TypePtr::BOTTOM;
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Meet over the PTR enum
0N/Aconst TypePtr::PTR TypePtr::ptr_meet[TypePtr::lastPTR][TypePtr::lastPTR] = {
0N/A // TopPTR, AnyNull, Constant, Null, NotNull, BotPTR,
0N/A { /* Top */ TopPTR, AnyNull, Constant, Null, NotNull, BotPTR,},
0N/A { /* AnyNull */ AnyNull, AnyNull, Constant, BotPTR, NotNull, BotPTR,},
0N/A { /* Constant*/ Constant, Constant, Constant, BotPTR, NotNull, BotPTR,},
0N/A { /* Null */ Null, BotPTR, BotPTR, Null, BotPTR, BotPTR,},
0N/A { /* NotNull */ NotNull, NotNull, NotNull, BotPTR, NotNull, BotPTR,},
0N/A { /* BotPTR */ BotPTR, BotPTR, BotPTR, BotPTR, BotPTR, BotPTR,}
0N/A};
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypePtr *TypePtr::make( TYPES t, enum PTR ptr, int offset ) {
0N/A return (TypePtr*)(new TypePtr(t,ptr,offset))->hashcons();
0N/A}
0N/A
0N/A//------------------------------cast_to_ptr_type-------------------------------
0N/Aconst Type *TypePtr::cast_to_ptr_type(PTR ptr) const {
0N/A assert(_base == AnyPtr, "subclass must override cast_to_ptr_type");
0N/A if( ptr == _ptr ) return this;
0N/A return make(_base, ptr, _offset);
0N/A}
0N/A
0N/A//------------------------------get_con----------------------------------------
0N/Aintptr_t TypePtr::get_con() const {
0N/A assert( _ptr == Null, "" );
0N/A return _offset;
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypePtr::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is AnyPtr
0N/A switch (t->base()) { // switch on original type
0N/A case Int: // Mixing ints & oops happens when javac
0N/A case Long: // reuses local variables
0N/A case FloatTop:
0N/A case FloatCon:
0N/A case FloatBot:
0N/A case DoubleTop:
0N/A case DoubleCon:
0N/A case DoubleBot:
113N/A case NarrowOop:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A case Top:
0N/A return this;
0N/A
0N/A case AnyPtr: { // Meeting to AnyPtrs
0N/A const TypePtr *tp = t->is_ptr();
0N/A return make( AnyPtr, meet_ptr(tp->ptr()), meet_offset(tp->offset()) );
0N/A }
0N/A case RawPtr: // For these, flip the call around to cut down
0N/A case OopPtr:
0N/A case InstPtr: // on the cases I have to handle.
0N/A case KlassPtr:
0N/A case AryPtr:
0N/A return t->xmeet(this); // Call in reverse direction
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A }
0N/A return this;
0N/A}
0N/A
0N/A//------------------------------meet_offset------------------------------------
0N/Aint TypePtr::meet_offset( int offset ) const {
0N/A // Either is 'TOP' offset? Return the other offset!
0N/A if( _offset == OffsetTop ) return offset;
0N/A if( offset == OffsetTop ) return _offset;
0N/A // If either is different, return 'BOTTOM' offset
0N/A if( _offset != offset ) return OffsetBot;
0N/A return _offset;
0N/A}
0N/A
0N/A//------------------------------dual_offset------------------------------------
0N/Aint TypePtr::dual_offset( ) const {
0N/A if( _offset == OffsetTop ) return OffsetBot;// Map 'TOP' into 'BOTTOM'
0N/A if( _offset == OffsetBot ) return OffsetTop;// Map 'BOTTOM' into 'TOP'
0N/A return _offset; // Map everything else into self
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: compute field-by-field dual
0N/Aconst TypePtr::PTR TypePtr::ptr_dual[TypePtr::lastPTR] = {
0N/A BotPTR, NotNull, Constant, Null, AnyNull, TopPTR
0N/A};
0N/Aconst Type *TypePtr::xdual() const {
0N/A return new TypePtr( AnyPtr, dual_ptr(), dual_offset() );
0N/A}
0N/A
306N/A//------------------------------xadd_offset------------------------------------
306N/Aint TypePtr::xadd_offset( intptr_t offset ) const {
306N/A // Adding to 'TOP' offset? Return 'TOP'!
306N/A if( _offset == OffsetTop || offset == OffsetTop ) return OffsetTop;
306N/A // Adding to 'BOTTOM' offset? Return 'BOTTOM'!
306N/A if( _offset == OffsetBot || offset == OffsetBot ) return OffsetBot;
306N/A // Addition overflows or "accidentally" equals to OffsetTop? Return 'BOTTOM'!
306N/A offset += (intptr_t)_offset;
306N/A if (offset != (int)offset || offset == OffsetTop) return OffsetBot;
306N/A
306N/A // assert( _offset >= 0 && _offset+offset >= 0, "" );
306N/A // It is possible to construct a negative offset during PhaseCCP
306N/A
306N/A return (int)offset; // Sum valid offsets
306N/A}
306N/A
0N/A//------------------------------add_offset-------------------------------------
306N/Aconst TypePtr *TypePtr::add_offset( intptr_t offset ) const {
306N/A return make( AnyPtr, _ptr, xadd_offset(offset) );
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypePtr::eq( const Type *t ) const {
0N/A const TypePtr *a = (const TypePtr*)t;
0N/A return _ptr == a->ptr() && _offset == a->offset();
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypePtr::hash(void) const {
0N/A return _ptr + _offset;
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/Aconst char *const TypePtr::ptr_msg[TypePtr::lastPTR] = {
0N/A "TopPTR","AnyNull","Constant","NULL","NotNull","BotPTR"
0N/A};
0N/A
0N/A#ifndef PRODUCT
0N/Avoid TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A if( _ptr == Null ) st->print("NULL");
0N/A else st->print("%s *", ptr_msg[_ptr]);
0N/A if( _offset == OffsetTop ) st->print("+top");
0N/A else if( _offset == OffsetBot ) st->print("+bot");
0N/A else if( _offset ) st->print("+%d", _offset);
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants
0N/Abool TypePtr::singleton(void) const {
0N/A // TopPTR, Null, AnyNull, Constant are all singletons
0N/A return (_offset != OffsetBot) && !below_centerline(_ptr);
0N/A}
0N/A
0N/Abool TypePtr::empty(void) const {
0N/A return (_offset == OffsetTop) || above_centerline(_ptr);
0N/A}
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst TypeRawPtr *TypeRawPtr::BOTTOM;
0N/Aconst TypeRawPtr *TypeRawPtr::NOTNULL;
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeRawPtr *TypeRawPtr::make( enum PTR ptr ) {
0N/A assert( ptr != Constant, "what is the constant?" );
0N/A assert( ptr != Null, "Use TypePtr for NULL" );
0N/A return (TypeRawPtr*)(new TypeRawPtr(ptr,0))->hashcons();
0N/A}
0N/A
0N/Aconst TypeRawPtr *TypeRawPtr::make( address bits ) {
0N/A assert( bits, "Use TypePtr for NULL" );
0N/A return (TypeRawPtr*)(new TypeRawPtr(Constant,bits))->hashcons();
0N/A}
0N/A
0N/A//------------------------------cast_to_ptr_type-------------------------------
0N/Aconst Type *TypeRawPtr::cast_to_ptr_type(PTR ptr) const {
0N/A assert( ptr != Constant, "what is the constant?" );
0N/A assert( ptr != Null, "Use TypePtr for NULL" );
0N/A assert( _bits==0, "Why cast a constant address?");
0N/A if( ptr == _ptr ) return this;
0N/A return make(ptr);
0N/A}
0N/A
0N/A//------------------------------get_con----------------------------------------
0N/Aintptr_t TypeRawPtr::get_con() const {
0N/A assert( _ptr == Null || _ptr == Constant, "" );
0N/A return (intptr_t)_bits;
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeRawPtr::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is RawPtr
0N/A switch( t->base() ) { // switch on original type
0N/A case Bottom: // Ye Olde Default
0N/A return t;
0N/A case Top:
0N/A return this;
0N/A case AnyPtr: // Meeting to AnyPtrs
0N/A break;
0N/A case RawPtr: { // might be top, bot, any/not or constant
0N/A enum PTR tptr = t->is_ptr()->ptr();
0N/A enum PTR ptr = meet_ptr( tptr );
0N/A if( ptr == Constant ) { // Cannot be equal constants, so...
0N/A if( tptr == Constant && _ptr != Constant) return t;
0N/A if( _ptr == Constant && tptr != Constant) return this;
0N/A ptr = NotNull; // Fall down in lattice
0N/A }
0N/A return make( ptr );
0N/A }
0N/A
0N/A case OopPtr:
0N/A case InstPtr:
0N/A case KlassPtr:
0N/A case AryPtr:
0N/A return TypePtr::BOTTOM; // Oop meet raw is not well defined
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A }
0N/A
0N/A // Found an AnyPtr type vs self-RawPtr type
0N/A const TypePtr *tp = t->is_ptr();
0N/A switch (tp->ptr()) {
0N/A case TypePtr::TopPTR: return this;
0N/A case TypePtr::BotPTR: return t;
0N/A case TypePtr::Null:
0N/A if( _ptr == TypePtr::TopPTR ) return t;
0N/A return TypeRawPtr::BOTTOM;
0N/A case TypePtr::NotNull: return TypePtr::make( AnyPtr, meet_ptr(TypePtr::NotNull), tp->meet_offset(0) );
0N/A case TypePtr::AnyNull:
0N/A if( _ptr == TypePtr::Constant) return this;
0N/A return make( meet_ptr(TypePtr::AnyNull) );
0N/A default: ShouldNotReachHere();
0N/A }
0N/A return this;
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: compute field-by-field dual
0N/Aconst Type *TypeRawPtr::xdual() const {
0N/A return new TypeRawPtr( dual_ptr(), _bits );
0N/A}
0N/A
0N/A//------------------------------add_offset-------------------------------------
306N/Aconst TypePtr *TypeRawPtr::add_offset( intptr_t offset ) const {
0N/A if( offset == OffsetTop ) return BOTTOM; // Undefined offset-> undefined pointer
0N/A if( offset == OffsetBot ) return BOTTOM; // Unknown offset-> unknown pointer
0N/A if( offset == 0 ) return this; // No change
0N/A switch (_ptr) {
0N/A case TypePtr::TopPTR:
0N/A case TypePtr::BotPTR:
0N/A case TypePtr::NotNull:
0N/A return this;
0N/A case TypePtr::Null:
2000N/A case TypePtr::Constant: {
2000N/A address bits = _bits+offset;
2000N/A if ( bits == 0 ) return TypePtr::NULL_PTR;
2000N/A return make( bits );
2000N/A }
0N/A default: ShouldNotReachHere();
0N/A }
0N/A return NULL; // Lint noise
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeRawPtr::eq( const Type *t ) const {
0N/A const TypeRawPtr *a = (const TypeRawPtr*)t;
0N/A return _bits == a->_bits && TypePtr::eq(t);
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeRawPtr::hash(void) const {
0N/A return (intptr_t)_bits + TypePtr::hash();
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A#ifndef PRODUCT
0N/Avoid TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A if( _ptr == Constant )
0N/A st->print(INTPTR_FORMAT, _bits);
0N/A else
0N/A st->print("rawptr:%s", ptr_msg[_ptr]);
0N/A}
0N/A#endif
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built type.
0N/Aconst TypeOopPtr *TypeOopPtr::BOTTOM;
0N/A
163N/A//------------------------------TypeOopPtr-------------------------------------
163N/ATypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id )
163N/A : TypePtr(t, ptr, offset),
163N/A _const_oop(o), _klass(k),
163N/A _klass_is_exact(xk),
163N/A _is_ptr_to_narrowoop(false),
163N/A _instance_id(instance_id) {
163N/A#ifdef _LP64
163N/A if (UseCompressedOops && _offset != 0) {
163N/A if (klass() == NULL) {
163N/A assert(this->isa_aryptr(), "only arrays without klass");
163N/A _is_ptr_to_narrowoop = true;
163N/A } else if (_offset == oopDesc::klass_offset_in_bytes()) {
163N/A _is_ptr_to_narrowoop = true;
163N/A } else if (this->isa_aryptr()) {
163N/A _is_ptr_to_narrowoop = (klass()->is_obj_array_klass() &&
163N/A _offset != arrayOopDesc::length_offset_in_bytes());
163N/A } else if (klass()->is_instance_klass()) {
163N/A ciInstanceKlass* ik = klass()->as_instance_klass();
163N/A ciField* field = NULL;
163N/A if (this->isa_klassptr()) {
2223N/A // Perm objects don't use compressed references
163N/A } else if (_offset == OffsetBot || _offset == OffsetTop) {
163N/A // unsafe access
163N/A _is_ptr_to_narrowoop = true;
163N/A } else { // exclude unsafe ops
163N/A assert(this->isa_instptr(), "must be an instance ptr.");
2223N/A
2223N/A if (klass() == ciEnv::current()->Class_klass() &&
2223N/A (_offset == java_lang_Class::klass_offset_in_bytes() ||
2223N/A _offset == java_lang_Class::array_klass_offset_in_bytes())) {
2223N/A // Special hidden fields from the Class.
2223N/A assert(this->isa_instptr(), "must be an instance ptr.");
2223N/A _is_ptr_to_narrowoop = true;
2223N/A } else if (klass() == ciEnv::current()->Class_klass() &&
2223N/A _offset >= instanceMirrorKlass::offset_of_static_fields()) {
2223N/A // Static fields
2223N/A assert(o != NULL, "must be constant");
2223N/A ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
2223N/A ciField* field = k->get_field_by_offset(_offset, true);
2223N/A assert(field != NULL, "missing field");
163N/A BasicType basic_elem_type = field->layout_type();
163N/A _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
163N/A basic_elem_type == T_ARRAY);
163N/A } else {
2223N/A // Instance fields which contains a compressed oop references.
2223N/A field = ik->get_field_by_offset(_offset, false);
2223N/A if (field != NULL) {
2223N/A BasicType basic_elem_type = field->layout_type();
2223N/A _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
2223N/A basic_elem_type == T_ARRAY);
2223N/A } else if (klass()->equals(ciEnv::current()->Object_klass())) {
2223N/A // Compile::find_alias_type() cast exactness on all types to verify
2223N/A // that it does not affect alias type.
2223N/A _is_ptr_to_narrowoop = true;
2223N/A } else {
2223N/A // Type for the copy start in LibraryCallKit::inline_native_clone().
2223N/A assert(!klass_is_exact(), "only non-exact klass");
2223N/A _is_ptr_to_narrowoop = true;
2223N/A }
163N/A }
163N/A }
163N/A }
163N/A }
163N/A#endif
163N/A}
163N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeOopPtr *TypeOopPtr::make(PTR ptr,
958N/A int offset, int instance_id) {
0N/A assert(ptr != Constant, "no constant generic pointers");
0N/A ciKlass* k = ciKlassKlass::make();
0N/A bool xk = false;
0N/A ciObject* o = NULL;
958N/A return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id))->hashcons();
0N/A}
0N/A
0N/A
0N/A//------------------------------cast_to_ptr_type-------------------------------
0N/Aconst Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
0N/A assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
0N/A if( ptr == _ptr ) return this;
992N/A return make(ptr, _offset, _instance_id);
0N/A}
0N/A
247N/A//-----------------------------cast_to_instance_id----------------------------
223N/Aconst TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
0N/A // There are no instances of a general oop.
0N/A // Return self unchanged.
0N/A return this;
0N/A}
0N/A
0N/A//-----------------------------cast_to_exactness-------------------------------
0N/Aconst Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
0N/A // There is no such thing as an exact general oop.
0N/A // Return self unchanged.
0N/A return this;
0N/A}
0N/A
0N/A
0N/A//------------------------------as_klass_type----------------------------------
0N/A// Return the klass type corresponding to this instance or array type.
0N/A// It is the type that is loaded from an object of this type.
0N/Aconst TypeKlassPtr* TypeOopPtr::as_klass_type() const {
0N/A ciKlass* k = klass();
0N/A bool xk = klass_is_exact();
0N/A if (k == NULL || !k->is_java_klass())
0N/A return TypeKlassPtr::OBJECT;
0N/A else
0N/A return TypeKlassPtr::make(xk? Constant: NotNull, k, 0);
0N/A}
0N/A
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeOopPtr::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is OopPtr
0N/A switch (t->base()) { // switch on original type
0N/A
0N/A case Int: // Mixing ints & oops happens when javac
0N/A case Long: // reuses local variables
0N/A case FloatTop:
0N/A case FloatCon:
0N/A case FloatBot:
0N/A case DoubleTop:
0N/A case DoubleCon:
0N/A case DoubleBot:
293N/A case NarrowOop:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A case Top:
0N/A return this;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case RawPtr:
0N/A return TypePtr::BOTTOM; // Oop meet raw is not well defined
0N/A
0N/A case AnyPtr: {
0N/A // Found an AnyPtr type vs self-OopPtr type
0N/A const TypePtr *tp = t->is_ptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
0N/A switch (tp->ptr()) {
0N/A case Null:
0N/A if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset);
0N/A // else fall through:
0N/A case TopPTR:
992N/A case AnyNull: {
992N/A int instance_id = meet_instance_id(InstanceTop);
992N/A return make(ptr, offset, instance_id);
992N/A }
0N/A case BotPTR:
0N/A case NotNull:
0N/A return TypePtr::make(AnyPtr, ptr, offset);
0N/A default: typerr(t);
0N/A }
0N/A }
0N/A
0N/A case OopPtr: { // Meeting to other OopPtrs
0N/A const TypeOopPtr *tp = t->is_oopptr();
958N/A int instance_id = meet_instance_id(tp->instance_id());
958N/A return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id );
0N/A }
0N/A
0N/A case InstPtr: // For these, flip the call around to cut down
0N/A case KlassPtr: // on the cases I have to handle.
0N/A case AryPtr:
0N/A return t->xmeet(this); // Call in reverse direction
0N/A
0N/A } // End of switch
0N/A return this; // Return the double constant
0N/A}
0N/A
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual of a pure heap pointer. No relevant klass or oop information.
0N/Aconst Type *TypeOopPtr::xdual() const {
0N/A assert(klass() == ciKlassKlass::make(), "no klasses here");
0N/A assert(const_oop() == NULL, "no constants here");
223N/A return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() );
0N/A}
0N/A
0N/A//--------------------------make_from_klass_common-----------------------------
0N/A// Computes the element-type given a klass.
0N/Aconst TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
0N/A assert(klass->is_java_klass(), "must be java language klass");
0N/A if (klass->is_instance_klass()) {
0N/A Compile* C = Compile::current();
0N/A Dependencies* deps = C->dependencies();
0N/A assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity");
0N/A // Element is an instance
0N/A bool klass_is_exact = false;
0N/A if (klass->is_loaded()) {
0N/A // Try to set klass_is_exact.
0N/A ciInstanceKlass* ik = klass->as_instance_klass();
0N/A klass_is_exact = ik->is_final();
0N/A if (!klass_is_exact && klass_change
0N/A && deps != NULL && UseUniqueSubclasses) {
0N/A ciInstanceKlass* sub = ik->unique_concrete_subklass();
0N/A if (sub != NULL) {
0N/A deps->assert_abstract_with_unique_concrete_subtype(ik, sub);
0N/A klass = ik = sub;
0N/A klass_is_exact = sub->is_final();
0N/A }
0N/A }
0N/A if (!klass_is_exact && try_for_exact
0N/A && deps != NULL && UseExactTypes) {
0N/A if (!ik->is_interface() && !ik->has_subklass()) {
0N/A // Add a dependence; if concrete subclass added we need to recompile
0N/A deps->assert_leaf_type(ik);
0N/A klass_is_exact = true;
0N/A }
0N/A }
0N/A }
0N/A return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, 0);
0N/A } else if (klass->is_obj_array_klass()) {
0N/A // Element is an object array. Recursively call ourself.
0N/A const TypeOopPtr *etype = TypeOopPtr::make_from_klass_common(klass->as_obj_array_klass()->element_klass(), false, try_for_exact);
0N/A bool xk = etype->klass_is_exact();
0N/A const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
0N/A // We used to pass NotNull in here, asserting that the sub-arrays
0N/A // are all not-null. This is not true in generally, as code can
0N/A // slam NULLs down in the subarrays.
0N/A const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0);
0N/A return arr;
0N/A } else if (klass->is_type_array_klass()) {
0N/A // Element is an typeArray
0N/A const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
0N/A const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
0N/A // We used to pass NotNull in here, asserting that the array pointer
0N/A // is not-null. That was not true in general.
0N/A const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0);
0N/A return arr;
0N/A } else {
0N/A ShouldNotReachHere();
0N/A return NULL;
0N/A }
0N/A}
0N/A
0N/A//------------------------------make_from_constant-----------------------------
0N/A// Make a java pointer from an oop constant
989N/Aconst TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) {
3848N/A if (o->is_method_data() || o->is_method()) {
0N/A // Treat much like a typeArray of bytes, like below, but fake the type...
3848N/A const BasicType bt = T_BYTE;
3848N/A const Type* etype = get_const_basic_type(bt);
0N/A const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
3848N/A ciKlass* klass = ciArrayKlass::make(ciType::make(bt));
3848N/A assert(o->can_be_constant(), "should be tenured");
3848N/A return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
3848N/A } else if (o->is_cpcache()) {
3848N/A // Treat much like a objArray, like below, but fake the type...
3848N/A const BasicType bt = T_OBJECT;
3848N/A const Type* etype = get_const_basic_type(bt);
3848N/A const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
3848N/A ciKlass* klass = ciArrayKlass::make(ciType::make(bt));
3848N/A assert(o->can_be_constant(), "should be tenured");
3848N/A return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
0N/A } else {
0N/A assert(o->is_java_object(), "must be java language object");
0N/A assert(!o->is_null_object(), "null object not yet handled here.");
3848N/A ciKlass* klass = o->klass();
0N/A if (klass->is_instance_klass()) {
0N/A // Element is an instance
989N/A if (require_constant) {
989N/A if (!o->can_be_constant()) return NULL;
989N/A } else if (!o->should_be_constant()) {
0N/A return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
0N/A }
0N/A return TypeInstPtr::make(o);
0N/A } else if (klass->is_obj_array_klass()) {
0N/A // Element is an object array. Recursively call ourself.
3848N/A const Type *etype = make_from_klass_raw(klass->as_obj_array_klass()->element_klass());
0N/A const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
0N/A // We used to pass NotNull in here, asserting that the sub-arrays
0N/A // are all not-null. This is not true in generally, as code can
0N/A // slam NULLs down in the subarrays.
989N/A if (require_constant) {
989N/A if (!o->can_be_constant()) return NULL;
989N/A } else if (!o->should_be_constant()) {
0N/A return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
0N/A }
3848N/A return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
0N/A } else if (klass->is_type_array_klass()) {
0N/A // Element is an typeArray
3848N/A const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
0N/A const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
0N/A // We used to pass NotNull in here, asserting that the array pointer
0N/A // is not-null. That was not true in general.
989N/A if (require_constant) {
989N/A if (!o->can_be_constant()) return NULL;
989N/A } else if (!o->should_be_constant()) {
0N/A return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
0N/A }
3848N/A return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
0N/A }
0N/A }
0N/A
3848N/A fatal("unhandled object type");
0N/A return NULL;
0N/A}
0N/A
0N/A//------------------------------get_con----------------------------------------
0N/Aintptr_t TypeOopPtr::get_con() const {
0N/A assert( _ptr == Null || _ptr == Constant, "" );
0N/A assert( _offset >= 0, "" );
0N/A
0N/A if (_offset != 0) {
0N/A // After being ported to the compiler interface, the compiler no longer
0N/A // directly manipulates the addresses of oops. Rather, it only has a pointer
0N/A // to a handle at compile time. This handle is embedded in the generated
0N/A // code and dereferenced at the time the nmethod is made. Until that time,
0N/A // it is not reasonable to do arithmetic with the addresses of oops (we don't
0N/A // have access to the addresses!). This does not seem to currently happen,
605N/A // but this assertion here is to help prevent its occurence.
0N/A tty->print_cr("Found oop constant with non-zero offset");
0N/A ShouldNotReachHere();
0N/A }
0N/A
989N/A return (intptr_t)const_oop()->constant_encoding();
0N/A}
0N/A
0N/A
0N/A//-----------------------------filter------------------------------------------
0N/A// Do not allow interface-vs.-noninterface joins to collapse to top.
0N/Aconst Type *TypeOopPtr::filter( const Type *kills ) const {
0N/A
0N/A const Type* ft = join(kills);
0N/A const TypeInstPtr* ftip = ft->isa_instptr();
0N/A const TypeInstPtr* ktip = kills->isa_instptr();
555N/A const TypeKlassPtr* ftkp = ft->isa_klassptr();
555N/A const TypeKlassPtr* ktkp = kills->isa_klassptr();
0N/A
0N/A if (ft->empty()) {
0N/A // Check for evil case of 'this' being a class and 'kills' expecting an
0N/A // interface. This can happen because the bytecodes do not contain
0N/A // enough type info to distinguish a Java-level interface variable
0N/A // from a Java-level object variable. If we meet 2 classes which
0N/A // both implement interface I, but their meet is at 'j/l/O' which
0N/A // doesn't implement I, we have no way to tell if the result should
0N/A // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows
0N/A // into a Phi which "knows" it's an Interface type we'll have to
0N/A // uplift the type.
0N/A if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface())
0N/A return kills; // Uplift to interface
555N/A if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface())
555N/A return kills; // Uplift to interface
0N/A
0N/A return Type::TOP; // Canonical empty value
0N/A }
0N/A
0N/A // If we have an interface-typed Phi or cast and we narrow to a class type,
0N/A // the join should report back the class. However, if we have a J/L/Object
0N/A // class-typed Phi and an interface flows in, it's possible that the meet &
0N/A // join report an interface back out. This isn't possible but happens
0N/A // because the type system doesn't interact well with interfaces.
0N/A if (ftip != NULL && ktip != NULL &&
0N/A ftip->is_loaded() && ftip->klass()->is_interface() &&
0N/A ktip->is_loaded() && !ktip->klass()->is_interface()) {
0N/A // Happens in a CTW of rt.jar, 320-341, no extra flags
1335N/A assert(!ftip->klass_is_exact(), "interface could not be exact");
0N/A return ktip->cast_to_ptr_type(ftip->ptr());
0N/A }
1335N/A // Interface klass type could be exact in opposite to interface type,
1335N/A // return it here instead of incorrect Constant ptr J/L/Object (6894807).
555N/A if (ftkp != NULL && ktkp != NULL &&
555N/A ftkp->is_loaded() && ftkp->klass()->is_interface() &&
1335N/A !ftkp->klass_is_exact() && // Keep exact interface klass
555N/A ktkp->is_loaded() && !ktkp->klass()->is_interface()) {
555N/A return ktkp->cast_to_ptr_type(ftkp->ptr());
555N/A }
0N/A
0N/A return ft;
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeOopPtr::eq( const Type *t ) const {
0N/A const TypeOopPtr *a = (const TypeOopPtr*)t;
0N/A if (_klass_is_exact != a->_klass_is_exact ||
0N/A _instance_id != a->_instance_id) return false;
0N/A ciObject* one = const_oop();
0N/A ciObject* two = a->const_oop();
0N/A if (one == NULL || two == NULL) {
0N/A return (one == two) && TypePtr::eq(t);
0N/A } else {
0N/A return one->equals(two) && TypePtr::eq(t);
0N/A }
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeOopPtr::hash(void) const {
0N/A return
0N/A (const_oop() ? const_oop()->hash() : 0) +
0N/A _klass_is_exact +
0N/A _instance_id +
0N/A TypePtr::hash();
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A#ifndef PRODUCT
0N/Avoid TypeOopPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A st->print("oopptr:%s", ptr_msg[_ptr]);
0N/A if( _klass_is_exact ) st->print(":exact");
0N/A if( const_oop() ) st->print(INTPTR_FORMAT, const_oop());
0N/A switch( _offset ) {
0N/A case OffsetTop: st->print("+top"); break;
0N/A case OffsetBot: st->print("+any"); break;
0N/A case 0: break;
0N/A default: st->print("+%d",_offset); break;
0N/A }
223N/A if (_instance_id == InstanceTop)
223N/A st->print(",iid=top");
223N/A else if (_instance_id != InstanceBot)
0N/A st->print(",iid=%d",_instance_id);
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants
0N/Abool TypeOopPtr::singleton(void) const {
0N/A // detune optimizer to not generate constant oop + constant offset as a constant!
0N/A // TopPTR, Null, AnyNull, Constant are all singletons
0N/A return (_offset == 0) && !below_centerline(_ptr);
0N/A}
0N/A
0N/A//------------------------------add_offset-------------------------------------
306N/Aconst TypePtr *TypeOopPtr::add_offset( intptr_t offset ) const {
992N/A return make( _ptr, xadd_offset(offset), _instance_id);
0N/A}
0N/A
223N/A//------------------------------meet_instance_id--------------------------------
223N/Aint TypeOopPtr::meet_instance_id( int instance_id ) const {
223N/A // Either is 'TOP' instance? Return the other instance!
223N/A if( _instance_id == InstanceTop ) return instance_id;
223N/A if( instance_id == InstanceTop ) return _instance_id;
223N/A // If either is different, return 'BOTTOM' instance
223N/A if( _instance_id != instance_id ) return InstanceBot;
223N/A return _instance_id;
0N/A}
0N/A
223N/A//------------------------------dual_instance_id--------------------------------
223N/Aint TypeOopPtr::dual_instance_id( ) const {
223N/A if( _instance_id == InstanceTop ) return InstanceBot; // Map TOP into BOTTOM
223N/A if( _instance_id == InstanceBot ) return InstanceTop; // Map BOTTOM into TOP
223N/A return _instance_id; // Map everything else into self
223N/A}
223N/A
223N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst TypeInstPtr *TypeInstPtr::NOTNULL;
0N/Aconst TypeInstPtr *TypeInstPtr::BOTTOM;
0N/Aconst TypeInstPtr *TypeInstPtr::MIRROR;
0N/Aconst TypeInstPtr *TypeInstPtr::MARK;
0N/Aconst TypeInstPtr *TypeInstPtr::KLASS;
0N/A
0N/A//------------------------------TypeInstPtr-------------------------------------
0N/ATypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id)
0N/A : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id), _name(k->name()) {
0N/A assert(k != NULL &&
0N/A (k->is_loaded() || o == NULL),
0N/A "cannot have constants with non-loaded klass");
0N/A};
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeInstPtr *TypeInstPtr::make(PTR ptr,
0N/A ciKlass* k,
0N/A bool xk,
0N/A ciObject* o,
0N/A int offset,
0N/A int instance_id) {
0N/A assert( !k->is_loaded() || k->is_instance_klass() ||
0N/A k->is_method_klass(), "Must be for instance or method");
0N/A // Either const_oop() is NULL or else ptr is Constant
0N/A assert( (!o && ptr != Constant) || (o && ptr == Constant),
0N/A "constant pointers must have a value supplied" );
0N/A // Ptr is never Null
0N/A assert( ptr != Null, "NULL pointers are not typed" );
0N/A
247N/A assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
0N/A if (!UseExactTypes) xk = false;
0N/A if (ptr == Constant) {
0N/A // Note: This case includes meta-object constants, such as methods.
0N/A xk = true;
0N/A } else if (k->is_loaded()) {
0N/A ciInstanceKlass* ik = k->as_instance_klass();
0N/A if (!xk && ik->is_final()) xk = true; // no inexact final klass
0N/A if (xk && ik->is_interface()) xk = false; // no exact interface
0N/A }
0N/A
0N/A // Now hash this baby
0N/A TypeInstPtr *result =
0N/A (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id))->hashcons();
0N/A
0N/A return result;
0N/A}
0N/A
0N/A
0N/A//------------------------------cast_to_ptr_type-------------------------------
0N/Aconst Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
0N/A if( ptr == _ptr ) return this;
0N/A // Reconstruct _sig info here since not a problem with later lazy
0N/A // construction, _sig will show up on demand.
223N/A return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id);
0N/A}
0N/A
0N/A
0N/A//-----------------------------cast_to_exactness-------------------------------
0N/Aconst Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
0N/A if( klass_is_exact == _klass_is_exact ) return this;
0N/A if (!UseExactTypes) return this;
0N/A if (!_klass->is_loaded()) return this;
0N/A ciInstanceKlass* ik = _klass->as_instance_klass();
0N/A if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
0N/A if( ik->is_interface() ) return this; // cannot set xk
0N/A return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id);
0N/A}
0N/A
247N/A//-----------------------------cast_to_instance_id----------------------------
223N/Aconst TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
223N/A if( instance_id == _instance_id ) return this;
247N/A return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id);
0N/A}
0N/A
0N/A//------------------------------xmeet_unloaded---------------------------------
0N/A// Compute the MEET of two InstPtrs when at least one is unloaded.
0N/A// Assume classes are different since called after check for same name/class-loader
0N/Aconst TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
0N/A int off = meet_offset(tinst->offset());
0N/A PTR ptr = meet_ptr(tinst->ptr());
992N/A int instance_id = meet_instance_id(tinst->instance_id());
0N/A
0N/A const TypeInstPtr *loaded = is_loaded() ? this : tinst;
0N/A const TypeInstPtr *unloaded = is_loaded() ? tinst : this;
0N/A if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
0N/A //
0N/A // Meet unloaded class with java/lang/Object
0N/A //
0N/A // Meet
0N/A // | Unloaded Class
0N/A // Object | TOP | AnyNull | Constant | NotNull | BOTTOM |
0N/A // ===================================================================
0N/A // TOP | ..........................Unloaded......................|
0N/A // AnyNull | U-AN |................Unloaded......................|
0N/A // Constant | ... O-NN .................................. | O-BOT |
0N/A // NotNull | ... O-NN .................................. | O-BOT |
0N/A // BOTTOM | ........................Object-BOTTOM ..................|
0N/A //
0N/A assert(loaded->ptr() != TypePtr::Null, "insanity check");
0N/A //
0N/A if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
992N/A else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make( ptr, unloaded->klass(), false, NULL, off, instance_id ); }
0N/A else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
0N/A else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
0N/A if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
0N/A else { return TypeInstPtr::NOTNULL; }
0N/A }
0N/A else if( unloaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
0N/A
0N/A return unloaded->cast_to_ptr_type(TypePtr::AnyNull)->is_instptr();
0N/A }
0N/A
0N/A // Both are unloaded, not the same class, not Object
0N/A // Or meet unloaded with a different loaded class, not java/lang/Object
0N/A if( ptr != TypePtr::BotPTR ) {
0N/A return TypeInstPtr::NOTNULL;
0N/A }
0N/A return TypeInstPtr::BOTTOM;
0N/A}
0N/A
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeInstPtr::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is Pointer
0N/A switch (t->base()) { // switch on original type
0N/A
0N/A case Int: // Mixing ints & oops happens when javac
0N/A case Long: // reuses local variables
0N/A case FloatTop:
0N/A case FloatCon:
0N/A case FloatBot:
0N/A case DoubleTop:
0N/A case DoubleCon:
0N/A case DoubleBot:
113N/A case NarrowOop:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A case Top:
0N/A return this;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case RawPtr: return TypePtr::BOTTOM;
0N/A
0N/A case AryPtr: { // All arrays inherit from Object class
0N/A const TypeAryPtr *tp = t->is_aryptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
223N/A int instance_id = meet_instance_id(tp->instance_id());
0N/A switch (ptr) {
0N/A case TopPTR:
0N/A case AnyNull: // Fall 'down' to dual of object klass
0N/A if (klass()->equals(ciEnv::current()->Object_klass())) {
223N/A return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id);
0N/A } else {
0N/A // cannot subclass, so the meet has to fall badly below the centerline
0N/A ptr = NotNull;
223N/A instance_id = InstanceBot;
223N/A return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id);
0N/A }
0N/A case Constant:
0N/A case NotNull:
0N/A case BotPTR: // Fall down to object klass
0N/A // LCA is object_klass, but if we subclass from the top we can do better
0N/A if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
0N/A // If 'this' (InstPtr) is above the centerline and it is Object class
605N/A // then we can subclass in the Java class hierarchy.
0N/A if (klass()->equals(ciEnv::current()->Object_klass())) {
0N/A // that is, tp's array type is a subtype of my klass
1279N/A return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL),
1279N/A tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id);
0N/A }
0N/A }
0N/A // The other case cannot happen, since I cannot be a subtype of an array.
0N/A // The meet falls down to Object class below centerline.
0N/A if( ptr == Constant )
0N/A ptr = NotNull;
223N/A instance_id = InstanceBot;
223N/A return make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id );
0N/A default: typerr(t);
0N/A }
0N/A }
0N/A
0N/A case OopPtr: { // Meeting to OopPtrs
0N/A // Found a OopPtr type vs self-InstPtr type
958N/A const TypeOopPtr *tp = t->is_oopptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
0N/A switch (tp->ptr()) {
0N/A case TopPTR:
223N/A case AnyNull: {
223N/A int instance_id = meet_instance_id(InstanceTop);
0N/A return make(ptr, klass(), klass_is_exact(),
223N/A (ptr == Constant ? const_oop() : NULL), offset, instance_id);
223N/A }
0N/A case NotNull:
958N/A case BotPTR: {
958N/A int instance_id = meet_instance_id(tp->instance_id());
958N/A return TypeOopPtr::make(ptr, offset, instance_id);
958N/A }
0N/A default: typerr(t);
0N/A }
0N/A }
0N/A
0N/A case AnyPtr: { // Meeting to AnyPtrs
0N/A // Found an AnyPtr type vs self-InstPtr type
0N/A const TypePtr *tp = t->is_ptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
0N/A switch (tp->ptr()) {
0N/A case Null:
0N/A if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset );
223N/A // else fall through to AnyNull
0N/A case TopPTR:
223N/A case AnyNull: {
223N/A int instance_id = meet_instance_id(InstanceTop);
0N/A return make( ptr, klass(), klass_is_exact(),
223N/A (ptr == Constant ? const_oop() : NULL), offset, instance_id);
223N/A }
0N/A case NotNull:
0N/A case BotPTR:
0N/A return TypePtr::make( AnyPtr, ptr, offset );
0N/A default: typerr(t);
0N/A }
0N/A }
0N/A
0N/A /*
0N/A A-top }
0N/A / | \ } Tops
0N/A B-top A-any C-top }
0N/A | / | \ | } Any-nulls
0N/A B-any | C-any }
0N/A | | |
0N/A B-con A-con C-con } constants; not comparable across classes
0N/A | | |
0N/A B-not | C-not }
0N/A | \ | / | } not-nulls
0N/A B-bot A-not C-bot }
0N/A \ | / } Bottoms
0N/A A-bot }
0N/A */
0N/A
0N/A case InstPtr: { // Meeting 2 Oops?
0N/A // Found an InstPtr sub-type vs self-InstPtr type
0N/A const TypeInstPtr *tinst = t->is_instptr();
0N/A int off = meet_offset( tinst->offset() );
0N/A PTR ptr = meet_ptr( tinst->ptr() );
223N/A int instance_id = meet_instance_id(tinst->instance_id());
0N/A
0N/A // Check for easy case; klasses are equal (and perhaps not loaded!)
0N/A // If we have constants, then we created oops so classes are loaded
0N/A // and we can handle the constants further down. This case handles
0N/A // both-not-loaded or both-loaded classes
0N/A if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) {
0N/A return make( ptr, klass(), klass_is_exact(), NULL, off, instance_id );
0N/A }
0N/A
0N/A // Classes require inspection in the Java klass hierarchy. Must be loaded.
0N/A ciKlass* tinst_klass = tinst->klass();
0N/A ciKlass* this_klass = this->klass();
0N/A bool tinst_xk = tinst->klass_is_exact();
0N/A bool this_xk = this->klass_is_exact();
0N/A if (!tinst_klass->is_loaded() || !this_klass->is_loaded() ) {
0N/A // One of these classes has not been loaded
0N/A const TypeInstPtr *unloaded_meet = xmeet_unloaded(tinst);
0N/A#ifndef PRODUCT
0N/A if( PrintOpto && Verbose ) {
0N/A tty->print("meet of unloaded classes resulted in: "); unloaded_meet->dump(); tty->cr();
0N/A tty->print(" this == "); this->dump(); tty->cr();
0N/A tty->print(" tinst == "); tinst->dump(); tty->cr();
0N/A }
0N/A#endif
0N/A return unloaded_meet;
0N/A }
0N/A
0N/A // Handle mixing oops and interfaces first.
0N/A if( this_klass->is_interface() && !tinst_klass->is_interface() ) {
0N/A ciKlass *tmp = tinst_klass; // Swap interface around
0N/A tinst_klass = this_klass;
0N/A this_klass = tmp;
0N/A bool tmp2 = tinst_xk;
0N/A tinst_xk = this_xk;
0N/A this_xk = tmp2;
0N/A }
0N/A if (tinst_klass->is_interface() &&
0N/A !(this_klass->is_interface() ||
0N/A // Treat java/lang/Object as an honorary interface,
0N/A // because we need a bottom for the interface hierarchy.
0N/A this_klass == ciEnv::current()->Object_klass())) {
0N/A // Oop meets interface!
0N/A
0N/A // See if the oop subtypes (implements) interface.
0N/A ciKlass *k;
0N/A bool xk;
0N/A if( this_klass->is_subtype_of( tinst_klass ) ) {
0N/A // Oop indeed subtypes. Now keep oop or interface depending
0N/A // on whether we are both above the centerline or either is
0N/A // below the centerline. If we are on the centerline
0N/A // (e.g., Constant vs. AnyNull interface), use the constant.
0N/A k = below_centerline(ptr) ? tinst_klass : this_klass;
0N/A // If we are keeping this_klass, keep its exactness too.
0N/A xk = below_centerline(ptr) ? tinst_xk : this_xk;
0N/A } else { // Does not implement, fall to Object
0N/A // Oop does not implement interface, so mixing falls to Object
0N/A // just like the verifier does (if both are above the
0N/A // centerline fall to interface)
0N/A k = above_centerline(ptr) ? tinst_klass : ciEnv::current()->Object_klass();
0N/A xk = above_centerline(ptr) ? tinst_xk : false;
0N/A // Watch out for Constant vs. AnyNull interface.
0N/A if (ptr == Constant) ptr = NotNull; // forget it was a constant
247N/A instance_id = InstanceBot;
0N/A }
0N/A ciObject* o = NULL; // the Constant value, if any
0N/A if (ptr == Constant) {
0N/A // Find out which constant.
0N/A o = (this_klass == klass()) ? const_oop() : tinst->const_oop();
0N/A }
223N/A return make( ptr, k, xk, o, off, instance_id );
0N/A }
0N/A
0N/A // Either oop vs oop or interface vs interface or interface vs Object
0N/A
0N/A // !!! Here's how the symmetry requirement breaks down into invariants:
0N/A // If we split one up & one down AND they subtype, take the down man.
0N/A // If we split one up & one down AND they do NOT subtype, "fall hard".
0N/A // If both are up and they subtype, take the subtype class.
0N/A // If both are up and they do NOT subtype, "fall hard".
0N/A // If both are down and they subtype, take the supertype class.
0N/A // If both are down and they do NOT subtype, "fall hard".
0N/A // Constants treated as down.
0N/A
0N/A // Now, reorder the above list; observe that both-down+subtype is also
0N/A // "fall hard"; "fall hard" becomes the default case:
0N/A // If we split one up & one down AND they subtype, take the down man.
0N/A // If both are up and they subtype, take the subtype class.
0N/A
0N/A // If both are down and they subtype, "fall hard".
0N/A // If both are down and they do NOT subtype, "fall hard".
0N/A // If both are up and they do NOT subtype, "fall hard".
0N/A // If we split one up & one down AND they do NOT subtype, "fall hard".
0N/A
0N/A // If a proper subtype is exact, and we return it, we return it exactly.
0N/A // If a proper supertype is exact, there can be no subtyping relationship!
0N/A // If both types are equal to the subtype, exactness is and-ed below the
0N/A // centerline and or-ed above it. (N.B. Constants are always exact.)
0N/A
0N/A // Check for subtyping:
0N/A ciKlass *subtype = NULL;
0N/A bool subtype_exact = false;
0N/A if( tinst_klass->equals(this_klass) ) {
0N/A subtype = this_klass;
0N/A subtype_exact = below_centerline(ptr) ? (this_xk & tinst_xk) : (this_xk | tinst_xk);
0N/A } else if( !tinst_xk && this_klass->is_subtype_of( tinst_klass ) ) {
0N/A subtype = this_klass; // Pick subtyping class
0N/A subtype_exact = this_xk;
0N/A } else if( !this_xk && tinst_klass->is_subtype_of( this_klass ) ) {
0N/A subtype = tinst_klass; // Pick subtyping class
0N/A subtype_exact = tinst_xk;
0N/A }
0N/A
0N/A if( subtype ) {
0N/A if( above_centerline(ptr) ) { // both are up?
0N/A this_klass = tinst_klass = subtype;
0N/A this_xk = tinst_xk = subtype_exact;
0N/A } else if( above_centerline(this ->_ptr) && !above_centerline(tinst->_ptr) ) {
0N/A this_klass = tinst_klass; // tinst is down; keep down man
0N/A this_xk = tinst_xk;
0N/A } else if( above_centerline(tinst->_ptr) && !above_centerline(this ->_ptr) ) {
0N/A tinst_klass = this_klass; // this is down; keep down man
0N/A tinst_xk = this_xk;
0N/A } else {
0N/A this_xk = subtype_exact; // either they are equal, or we'll do an LCA
0N/A }
0N/A }
0N/A
0N/A // Check for classes now being equal
0N/A if (tinst_klass->equals(this_klass)) {
0N/A // If the klasses are equal, the constants may still differ. Fall to
0N/A // NotNull if they do (neither constant is NULL; that is a special case
0N/A // handled elsewhere).
0N/A ciObject* o = NULL; // Assume not constant when done
0N/A ciObject* this_oop = const_oop();
0N/A ciObject* tinst_oop = tinst->const_oop();
0N/A if( ptr == Constant ) {
0N/A if (this_oop != NULL && tinst_oop != NULL &&
0N/A this_oop->equals(tinst_oop) )
0N/A o = this_oop;
0N/A else if (above_centerline(this ->_ptr))
0N/A o = tinst_oop;
0N/A else if (above_centerline(tinst ->_ptr))
0N/A o = this_oop;
0N/A else
0N/A ptr = NotNull;
0N/A }
0N/A return make( ptr, this_klass, this_xk, o, off, instance_id );
0N/A } // Else classes are not equal
0N/A
0N/A // Since klasses are different, we require a LCA in the Java
0N/A // class hierarchy - which means we have to fall to at least NotNull.
0N/A if( ptr == TopPTR || ptr == AnyNull || ptr == Constant )
0N/A ptr = NotNull;
247N/A instance_id = InstanceBot;
0N/A
0N/A // Now we find the LCA of Java classes
0N/A ciKlass* k = this_klass->least_common_ancestor(tinst_klass);
223N/A return make( ptr, k, false, NULL, off, instance_id );
0N/A } // End of case InstPtr
0N/A
0N/A case KlassPtr:
0N/A return TypeInstPtr::BOTTOM;
0N/A
0N/A } // End of switch
0N/A return this; // Return the double constant
0N/A}
0N/A
0N/A
0N/A//------------------------java_mirror_type--------------------------------------
0N/AciType* TypeInstPtr::java_mirror_type() const {
0N/A // must be a singleton type
0N/A if( const_oop() == NULL ) return NULL;
0N/A
0N/A // must be of type java.lang.Class
0N/A if( klass() != ciEnv::current()->Class_klass() ) return NULL;
0N/A
0N/A return const_oop()->as_instance()->java_mirror_type();
0N/A}
0N/A
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: do NOT dual on klasses. This means I do NOT understand the Java
605N/A// inheritance mechanism.
0N/Aconst Type *TypeInstPtr::xdual() const {
223N/A return new TypeInstPtr( dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() );
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeInstPtr::eq( const Type *t ) const {
0N/A const TypeInstPtr *p = t->is_instptr();
0N/A return
0N/A klass()->equals(p->klass()) &&
0N/A TypeOopPtr::eq(p); // Check sub-type stuff
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeInstPtr::hash(void) const {
0N/A int hash = klass()->hash() + TypeOopPtr::hash();
0N/A return hash;
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A// Dump oop Type
0N/A#ifndef PRODUCT
0N/Avoid TypeInstPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A // Print the name of the klass.
0N/A klass()->print_name_on(st);
0N/A
0N/A switch( _ptr ) {
0N/A case Constant:
0N/A // TO DO: Make CI print the hex address of the underlying oop.
0N/A if (WizardMode || Verbose) {
0N/A const_oop()->print_oop(st);
0N/A }
0N/A case BotPTR:
0N/A if (!WizardMode && !Verbose) {
0N/A if( _klass_is_exact ) st->print(":exact");
0N/A break;
0N/A }
0N/A case TopPTR:
0N/A case AnyNull:
0N/A case NotNull:
0N/A st->print(":%s", ptr_msg[_ptr]);
0N/A if( _klass_is_exact ) st->print(":exact");
0N/A break;
0N/A }
0N/A
0N/A if( _offset ) { // Dump offset, if any
0N/A if( _offset == OffsetBot ) st->print("+any");
0N/A else if( _offset == OffsetTop ) st->print("+unknown");
0N/A else st->print("+%d", _offset);
0N/A }
0N/A
0N/A st->print(" *");
223N/A if (_instance_id == InstanceTop)
223N/A st->print(",iid=top");
223N/A else if (_instance_id != InstanceBot)
0N/A st->print(",iid=%d",_instance_id);
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------add_offset-------------------------------------
306N/Aconst TypePtr *TypeInstPtr::add_offset( intptr_t offset ) const {
0N/A return make( _ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id );
0N/A}
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/Aconst TypeAryPtr *TypeAryPtr::RANGE;
0N/Aconst TypeAryPtr *TypeAryPtr::OOPS;
163N/Aconst TypeAryPtr *TypeAryPtr::NARROWOOPS;
0N/Aconst TypeAryPtr *TypeAryPtr::BYTES;
0N/Aconst TypeAryPtr *TypeAryPtr::SHORTS;
0N/Aconst TypeAryPtr *TypeAryPtr::CHARS;
0N/Aconst TypeAryPtr *TypeAryPtr::INTS;
0N/Aconst TypeAryPtr *TypeAryPtr::LONGS;
0N/Aconst TypeAryPtr *TypeAryPtr::FLOATS;
0N/Aconst TypeAryPtr *TypeAryPtr::DOUBLES;
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeAryPtr *TypeAryPtr::make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) {
0N/A assert(!(k == NULL && ary->_elem->isa_int()),
0N/A "integral arrays must be pre-equipped with a class");
0N/A if (!xk) xk = ary->ary_must_be_exact();
247N/A assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
0N/A if (!UseExactTypes) xk = (ptr == Constant);
0N/A return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id))->hashcons();
0N/A}
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) {
0N/A assert(!(k == NULL && ary->_elem->isa_int()),
0N/A "integral arrays must be pre-equipped with a class");
0N/A assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
0N/A if (!xk) xk = (o != NULL) || ary->ary_must_be_exact();
247N/A assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
0N/A if (!UseExactTypes) xk = (ptr == Constant);
0N/A return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id))->hashcons();
0N/A}
0N/A
0N/A//------------------------------cast_to_ptr_type-------------------------------
0N/Aconst Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
0N/A if( ptr == _ptr ) return this;
223N/A return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id);
0N/A}
0N/A
0N/A
0N/A//-----------------------------cast_to_exactness-------------------------------
0N/Aconst Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
0N/A if( klass_is_exact == _klass_is_exact ) return this;
0N/A if (!UseExactTypes) return this;
0N/A if (_ary->ary_must_be_exact()) return this; // cannot clear xk
0N/A return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id);
0N/A}
0N/A
247N/A//-----------------------------cast_to_instance_id----------------------------
223N/Aconst TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
223N/A if( instance_id == _instance_id ) return this;
247N/A return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id);
0N/A}
0N/A
0N/A//-----------------------------narrow_size_type-------------------------------
0N/A// Local cache for arrayOopDesc::max_array_length(etype),
0N/A// which is kind of slow (and cached elsewhere by other users).
0N/Astatic jint max_array_length_cache[T_CONFLICT+1];
0N/Astatic jint max_array_length(BasicType etype) {
0N/A jint& cache = max_array_length_cache[etype];
0N/A jint res = cache;
0N/A if (res == 0) {
0N/A switch (etype) {
113N/A case T_NARROWOOP:
113N/A etype = T_OBJECT;
113N/A break;
0N/A case T_CONFLICT:
0N/A case T_ILLEGAL:
0N/A case T_VOID:
0N/A etype = T_BYTE; // will produce conservatively high value
0N/A }
0N/A cache = res = arrayOopDesc::max_array_length(etype);
0N/A }
0N/A return res;
0N/A}
0N/A
0N/A// Narrow the given size type to the index range for the given array base type.
0N/A// Return NULL if the resulting int type becomes empty.
366N/Aconst TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const {
0N/A jint hi = size->_hi;
0N/A jint lo = size->_lo;
0N/A jint min_lo = 0;
366N/A jint max_hi = max_array_length(elem()->basic_type());
0N/A //if (index_not_size) --max_hi; // type of a valid array index, FTR
0N/A bool chg = false;
0N/A if (lo < min_lo) { lo = min_lo; chg = true; }
0N/A if (hi > max_hi) { hi = max_hi; chg = true; }
605N/A // Negative length arrays will produce weird intermediate dead fast-path code
0N/A if (lo > hi)
366N/A return TypeInt::ZERO;
0N/A if (!chg)
0N/A return size;
0N/A return TypeInt::make(lo, hi, Type::WidenMin);
0N/A}
0N/A
0N/A//-------------------------------cast_to_size----------------------------------
0N/Aconst TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
0N/A assert(new_size != NULL, "");
366N/A new_size = narrow_size_type(new_size);
0N/A if (new_size == size()) return this;
0N/A const TypeAry* new_ary = TypeAry::make(elem(), new_size);
223N/A return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id);
0N/A}
0N/A
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeAryPtr::eq( const Type *t ) const {
0N/A const TypeAryPtr *p = t->is_aryptr();
0N/A return
0N/A _ary == p->_ary && // Check array
0N/A TypeOopPtr::eq(p); // Check sub-parts
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeAryPtr::hash(void) const {
0N/A return (intptr_t)_ary + TypeOopPtr::hash();
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeAryPtr::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A // Current "this->_base" is Pointer
0N/A switch (t->base()) { // switch on original type
0N/A
0N/A // Mixing ints & oops happens when javac reuses local variables
0N/A case Int:
0N/A case Long:
0N/A case FloatTop:
0N/A case FloatCon:
0N/A case FloatBot:
0N/A case DoubleTop:
0N/A case DoubleCon:
0N/A case DoubleBot:
113N/A case NarrowOop:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A case Top:
0N/A return this;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case OopPtr: { // Meeting to OopPtrs
0N/A // Found a OopPtr type vs self-AryPtr type
958N/A const TypeOopPtr *tp = t->is_oopptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
0N/A switch (tp->ptr()) {
0N/A case TopPTR:
223N/A case AnyNull: {
223N/A int instance_id = meet_instance_id(InstanceTop);
223N/A return make(ptr, (ptr == Constant ? const_oop() : NULL),
223N/A _ary, _klass, _klass_is_exact, offset, instance_id);
223N/A }
0N/A case BotPTR:
958N/A case NotNull: {
958N/A int instance_id = meet_instance_id(tp->instance_id());
958N/A return TypeOopPtr::make(ptr, offset, instance_id);
958N/A }
0N/A default: ShouldNotReachHere();
0N/A }
0N/A }
0N/A
0N/A case AnyPtr: { // Meeting two AnyPtrs
0N/A // Found an AnyPtr type vs self-AryPtr type
0N/A const TypePtr *tp = t->is_ptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
0N/A switch (tp->ptr()) {
0N/A case TopPTR:
0N/A return this;
0N/A case BotPTR:
0N/A case NotNull:
0N/A return TypePtr::make(AnyPtr, ptr, offset);
0N/A case Null:
0N/A if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset);
223N/A // else fall through to AnyNull
223N/A case AnyNull: {
223N/A int instance_id = meet_instance_id(InstanceTop);
223N/A return make( ptr, (ptr == Constant ? const_oop() : NULL),
223N/A _ary, _klass, _klass_is_exact, offset, instance_id);
223N/A }
0N/A default: ShouldNotReachHere();
0N/A }
0N/A }
0N/A
0N/A case RawPtr: return TypePtr::BOTTOM;
0N/A
0N/A case AryPtr: { // Meeting 2 references?
0N/A const TypeAryPtr *tap = t->is_aryptr();
0N/A int off = meet_offset(tap->offset());
0N/A const TypeAry *tary = _ary->meet(tap->_ary)->is_ary();
0N/A PTR ptr = meet_ptr(tap->ptr());
223N/A int instance_id = meet_instance_id(tap->instance_id());
0N/A ciKlass* lazy_klass = NULL;
0N/A if (tary->_elem->isa_int()) {
0N/A // Integral array element types have irrelevant lattice relations.
0N/A // It is the klass that determines array layout, not the element type.
0N/A if (_klass == NULL)
0N/A lazy_klass = tap->_klass;
0N/A else if (tap->_klass == NULL || tap->_klass == _klass) {
0N/A lazy_klass = _klass;
0N/A } else {
0N/A // Something like byte[int+] meets char[int+].
0N/A // This must fall to bottom, not (int[-128..65535])[int+].
247N/A instance_id = InstanceBot;
0N/A tary = TypeAry::make(Type::BOTTOM, tary->_size);
0N/A }
2198N/A } else // Non integral arrays.
2198N/A // Must fall to bottom if exact klasses in upper lattice
2198N/A // are not equal or super klass is exact.
2198N/A if ( above_centerline(ptr) && klass() != tap->klass() &&
2198N/A // meet with top[] and bottom[] are processed further down:
2198N/A tap ->_klass != NULL && this->_klass != NULL &&
2198N/A // both are exact and not equal:
2198N/A ((tap ->_klass_is_exact && this->_klass_is_exact) ||
2198N/A // 'tap' is exact and super or unrelated:
2198N/A (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) ||
2198N/A // 'this' is exact and super or unrelated:
2198N/A (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) {
2198N/A tary = TypeAry::make(Type::BOTTOM, tary->_size);
2198N/A return make( NotNull, NULL, tary, lazy_klass, false, off, InstanceBot );
0N/A }
2198N/A
1685N/A bool xk = false;
0N/A switch (tap->ptr()) {
0N/A case AnyNull:
0N/A case TopPTR:
0N/A // Compute new klass on demand, do not use tap->_klass
0N/A xk = (tap->_klass_is_exact | this->_klass_is_exact);
223N/A return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id );
0N/A case Constant: {
0N/A ciObject* o = const_oop();
0N/A if( _ptr == Constant ) {
0N/A if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) {
989N/A xk = (klass() == tap->klass());
0N/A ptr = NotNull;
0N/A o = NULL;
247N/A instance_id = InstanceBot;
989N/A } else {
989N/A xk = true;
0N/A }
0N/A } else if( above_centerline(_ptr) ) {
0N/A o = tap->const_oop();
989N/A xk = true;
989N/A } else {
1685N/A // Only precise for identical arrays
1685N/A xk = this->_klass_is_exact && (klass() == tap->klass());
0N/A }
1685N/A return TypeAryPtr::make( ptr, o, tary, lazy_klass, xk, off, instance_id );
0N/A }
0N/A case NotNull:
0N/A case BotPTR:
0N/A // Compute new klass on demand, do not use tap->_klass
0N/A if (above_centerline(this->_ptr))
0N/A xk = tap->_klass_is_exact;
0N/A else if (above_centerline(tap->_ptr))
0N/A xk = this->_klass_is_exact;
0N/A else xk = (tap->_klass_is_exact & this->_klass_is_exact) &&
0N/A (klass() == tap->klass()); // Only precise for identical arrays
223N/A return TypeAryPtr::make( ptr, NULL, tary, lazy_klass, xk, off, instance_id );
0N/A default: ShouldNotReachHere();
0N/A }
0N/A }
0N/A
0N/A // All arrays inherit from Object class
0N/A case InstPtr: {
0N/A const TypeInstPtr *tp = t->is_instptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
223N/A int instance_id = meet_instance_id(tp->instance_id());
0N/A switch (ptr) {
0N/A case TopPTR:
0N/A case AnyNull: // Fall 'down' to dual of object klass
0N/A if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) {
223N/A return TypeAryPtr::make( ptr, _ary, _klass, _klass_is_exact, offset, instance_id );
0N/A } else {
0N/A // cannot subclass, so the meet has to fall badly below the centerline
0N/A ptr = NotNull;
223N/A instance_id = InstanceBot;
223N/A return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id);
0N/A }
0N/A case Constant:
0N/A case NotNull:
0N/A case BotPTR: // Fall down to object klass
0N/A // LCA is object_klass, but if we subclass from the top we can do better
0N/A if (above_centerline(tp->ptr())) {
0N/A // If 'tp' is above the centerline and it is Object class
605N/A // then we can subclass in the Java class hierarchy.
0N/A if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) {
0N/A // that is, my array type is a subtype of 'tp' klass
1279N/A return make( ptr, (ptr == Constant ? const_oop() : NULL),
1279N/A _ary, _klass, _klass_is_exact, offset, instance_id );
0N/A }
0N/A }
0N/A // The other case cannot happen, since t cannot be a subtype of an array.
0N/A // The meet falls down to Object class below centerline.
0N/A if( ptr == Constant )
0N/A ptr = NotNull;
223N/A instance_id = InstanceBot;
223N/A return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id);
0N/A default: typerr(t);
0N/A }
0N/A }
0N/A
0N/A case KlassPtr:
0N/A return TypeInstPtr::BOTTOM;
0N/A
0N/A }
0N/A return this; // Lint noise
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: compute field-by-field dual
0N/Aconst Type *TypeAryPtr::xdual() const {
223N/A return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id() );
0N/A}
0N/A
820N/A//----------------------interface_vs_oop---------------------------------------
820N/A#ifdef ASSERT
820N/Abool TypeAryPtr::interface_vs_oop(const Type *t) const {
820N/A const TypeAryPtr* t_aryptr = t->isa_aryptr();
820N/A if (t_aryptr) {
820N/A return _ary->interface_vs_oop(t_aryptr->_ary);
820N/A }
820N/A return false;
820N/A}
820N/A#endif
820N/A
0N/A//------------------------------dump2------------------------------------------
0N/A#ifndef PRODUCT
0N/Avoid TypeAryPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A _ary->dump2(d,depth,st);
0N/A switch( _ptr ) {
0N/A case Constant:
0N/A const_oop()->print(st);
0N/A break;
0N/A case BotPTR:
0N/A if (!WizardMode && !Verbose) {
0N/A if( _klass_is_exact ) st->print(":exact");
0N/A break;
0N/A }
0N/A case TopPTR:
0N/A case AnyNull:
0N/A case NotNull:
0N/A st->print(":%s", ptr_msg[_ptr]);
0N/A if( _klass_is_exact ) st->print(":exact");
0N/A break;
0N/A }
0N/A
64N/A if( _offset != 0 ) {
64N/A int header_size = objArrayOopDesc::header_size() * wordSize;
64N/A if( _offset == OffsetTop ) st->print("+undefined");
64N/A else if( _offset == OffsetBot ) st->print("+any");
64N/A else if( _offset < header_size ) st->print("+%d", _offset);
64N/A else {
64N/A BasicType basic_elem_type = elem()->basic_type();
64N/A int array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
64N/A int elem_size = type2aelembytes(basic_elem_type);
64N/A st->print("[%d]", (_offset - array_base)/elem_size);
64N/A }
64N/A }
64N/A st->print(" *");
223N/A if (_instance_id == InstanceTop)
223N/A st->print(",iid=top");
223N/A else if (_instance_id != InstanceBot)
0N/A st->print(",iid=%d",_instance_id);
0N/A}
0N/A#endif
0N/A
0N/Abool TypeAryPtr::empty(void) const {
0N/A if (_ary->empty()) return true;
0N/A return TypeOopPtr::empty();
0N/A}
0N/A
0N/A//------------------------------add_offset-------------------------------------
306N/Aconst TypePtr *TypeAryPtr::add_offset( intptr_t offset ) const {
0N/A return make( _ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id );
0N/A}
0N/A
0N/A
0N/A//=============================================================================
113N/Aconst TypeNarrowOop *TypeNarrowOop::BOTTOM;
113N/Aconst TypeNarrowOop *TypeNarrowOop::NULL_PTR;
113N/A
113N/A
113N/Aconst TypeNarrowOop* TypeNarrowOop::make(const TypePtr* type) {
113N/A return (const TypeNarrowOop*)(new TypeNarrowOop(type))->hashcons();
113N/A}
113N/A
113N/A//------------------------------hash-------------------------------------------
113N/A// Type-specific hashing function.
113N/Aint TypeNarrowOop::hash(void) const {
827N/A return _ptrtype->hash() + 7;
113N/A}
113N/A
113N/A
113N/Abool TypeNarrowOop::eq( const Type *t ) const {
113N/A const TypeNarrowOop* tc = t->isa_narrowoop();
113N/A if (tc != NULL) {
827N/A if (_ptrtype->base() != tc->_ptrtype->base()) {
113N/A return false;
113N/A }
827N/A return tc->_ptrtype->eq(_ptrtype);
113N/A }
113N/A return false;
113N/A}
113N/A
113N/Abool TypeNarrowOop::singleton(void) const { // TRUE if type is a singleton
827N/A return _ptrtype->singleton();
113N/A}
113N/A
113N/Abool TypeNarrowOop::empty(void) const {
827N/A return _ptrtype->empty();
113N/A}
113N/A
293N/A//------------------------------xmeet------------------------------------------
113N/A// Compute the MEET of two types. It returns a new Type object.
113N/Aconst Type *TypeNarrowOop::xmeet( const Type *t ) const {
113N/A // Perform a fast test for common case; meeting the same types together.
113N/A if( this == t ) return this; // Meeting same type-rep?
113N/A
113N/A
113N/A // Current "this->_base" is OopPtr
113N/A switch (t->base()) { // switch on original type
113N/A
113N/A case Int: // Mixing ints & oops happens when javac
113N/A case Long: // reuses local variables
113N/A case FloatTop:
113N/A case FloatCon:
113N/A case FloatBot:
113N/A case DoubleTop:
113N/A case DoubleCon:
113N/A case DoubleBot:
293N/A case AnyPtr:
293N/A case RawPtr:
293N/A case OopPtr:
293N/A case InstPtr:
293N/A case KlassPtr:
293N/A case AryPtr:
293N/A
113N/A case Bottom: // Ye Olde Default
113N/A return Type::BOTTOM;
113N/A case Top:
113N/A return this;
113N/A
113N/A case NarrowOop: {
827N/A const Type* result = _ptrtype->xmeet(t->make_ptr());
113N/A if (result->isa_ptr()) {
113N/A return TypeNarrowOop::make(result->is_ptr());
113N/A }
113N/A return result;
113N/A }
113N/A
113N/A default: // All else is a mistake
113N/A typerr(t);
113N/A
113N/A } // End of switch
293N/A
293N/A return this;
113N/A}
113N/A
113N/Aconst Type *TypeNarrowOop::xdual() const { // Compute dual right now.
827N/A const TypePtr* odual = _ptrtype->dual()->is_ptr();
113N/A return new TypeNarrowOop(odual);
113N/A}
113N/A
113N/Aconst Type *TypeNarrowOop::filter( const Type *kills ) const {
113N/A if (kills->isa_narrowoop()) {
827N/A const Type* ft =_ptrtype->filter(kills->is_narrowoop()->_ptrtype);
113N/A if (ft->empty())
113N/A return Type::TOP; // Canonical empty value
113N/A if (ft->isa_ptr()) {
113N/A return make(ft->isa_ptr());
113N/A }
113N/A return ft;
113N/A } else if (kills->isa_ptr()) {
827N/A const Type* ft = _ptrtype->join(kills);
113N/A if (ft->empty())
113N/A return Type::TOP; // Canonical empty value
113N/A return ft;
113N/A } else {
113N/A return Type::TOP;
113N/A }
113N/A}
113N/A
113N/A
113N/Aintptr_t TypeNarrowOop::get_con() const {
827N/A return _ptrtype->get_con();
113N/A}
113N/A
113N/A#ifndef PRODUCT
113N/Avoid TypeNarrowOop::dump2( Dict & d, uint depth, outputStream *st ) const {
417N/A st->print("narrowoop: ");
827N/A _ptrtype->dump2(d, depth, st);
113N/A}
113N/A#endif
113N/A
113N/A
113N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/A
0N/A// Not-null object klass or below
0N/Aconst TypeKlassPtr *TypeKlassPtr::OBJECT;
0N/Aconst TypeKlassPtr *TypeKlassPtr::OBJECT_OR_NULL;
0N/A
0N/A//------------------------------TypeKlasPtr------------------------------------
0N/ATypeKlassPtr::TypeKlassPtr( PTR ptr, ciKlass* klass, int offset )
0N/A : TypeOopPtr(KlassPtr, ptr, klass, (ptr==Constant), (ptr==Constant ? klass : NULL), offset, 0) {
0N/A}
0N/A
0N/A//------------------------------make-------------------------------------------
0N/A// ptr to klass 'k', if Constant, or possibly to a sub-klass if not a Constant
0N/Aconst TypeKlassPtr *TypeKlassPtr::make( PTR ptr, ciKlass* k, int offset ) {
0N/A assert( k != NULL, "Expect a non-NULL klass");
0N/A assert(k->is_instance_klass() || k->is_array_klass() ||
0N/A k->is_method_klass(), "Incorrect type of klass oop");
0N/A TypeKlassPtr *r =
0N/A (TypeKlassPtr*)(new TypeKlassPtr(ptr, k, offset))->hashcons();
0N/A
0N/A return r;
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeKlassPtr::eq( const Type *t ) const {
0N/A const TypeKlassPtr *p = t->is_klassptr();
0N/A return
0N/A klass()->equals(p->klass()) &&
0N/A TypeOopPtr::eq(p);
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeKlassPtr::hash(void) const {
0N/A return klass()->hash() + TypeOopPtr::hash();
0N/A}
0N/A
0N/A
1681N/A//----------------------compute_klass------------------------------------------
1681N/A// Compute the defining klass for this class
1681N/AciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const {
1681N/A // Compute _klass based on element type.
0N/A ciKlass* k_ary = NULL;
0N/A const TypeInstPtr *tinst;
0N/A const TypeAryPtr *tary;
113N/A const Type* el = elem();
113N/A if (el->isa_narrowoop()) {
221N/A el = el->make_ptr();
113N/A }
113N/A
0N/A // Get element klass
113N/A if ((tinst = el->isa_instptr()) != NULL) {
0N/A // Compute array klass from element klass
0N/A k_ary = ciObjArrayKlass::make(tinst->klass());
113N/A } else if ((tary = el->isa_aryptr()) != NULL) {
0N/A // Compute array klass from element klass
0N/A ciKlass* k_elem = tary->klass();
0N/A // If element type is something like bottom[], k_elem will be null.
0N/A if (k_elem != NULL)
0N/A k_ary = ciObjArrayKlass::make(k_elem);
113N/A } else if ((el->base() == Type::Top) ||
113N/A (el->base() == Type::Bottom)) {
0N/A // element type of Bottom occurs from meet of basic type
0N/A // and object; Top occurs when doing join on Bottom.
0N/A // Leave k_ary at NULL.
0N/A } else {
0N/A // Cannot compute array klass directly from basic type,
0N/A // since subtypes of TypeInt all have basic type T_INT.
1681N/A#ifdef ASSERT
1681N/A if (verify && el->isa_int()) {
1681N/A // Check simple cases when verifying klass.
1681N/A BasicType bt = T_ILLEGAL;
1681N/A if (el == TypeInt::BYTE) {
1681N/A bt = T_BYTE;
1681N/A } else if (el == TypeInt::SHORT) {
1681N/A bt = T_SHORT;
1681N/A } else if (el == TypeInt::CHAR) {
1681N/A bt = T_CHAR;
1681N/A } else if (el == TypeInt::INT) {
1681N/A bt = T_INT;
1681N/A } else {
1681N/A return _klass; // just return specified klass
1681N/A }
1681N/A return ciTypeArrayKlass::make(bt);
1681N/A }
1681N/A#endif
113N/A assert(!el->isa_int(),
0N/A "integral arrays must be pre-equipped with a class");
0N/A // Compute array klass directly from basic type
113N/A k_ary = ciTypeArrayKlass::make(el->basic_type());
0N/A }
1681N/A return k_ary;
1681N/A}
1681N/A
1681N/A//------------------------------klass------------------------------------------
1681N/A// Return the defining klass for this class
1681N/AciKlass* TypeAryPtr::klass() const {
1681N/A if( _klass ) return _klass; // Return cached value, if possible
1681N/A
1681N/A // Oops, need to compute _klass and cache it
1681N/A ciKlass* k_ary = compute_klass();
0N/A
2201N/A if( this != TypeAryPtr::OOPS && this->dual() != TypeAryPtr::OOPS ) {
0N/A // The _klass field acts as a cache of the underlying
0N/A // ciKlass for this array type. In order to set the field,
0N/A // we need to cast away const-ness.
0N/A //
0N/A // IMPORTANT NOTE: we *never* set the _klass field for the
0N/A // type TypeAryPtr::OOPS. This Type is shared between all
0N/A // active compilations. However, the ciKlass which represents
0N/A // this Type is *not* shared between compilations, so caching
0N/A // this value would result in fetching a dangling pointer.
0N/A //
0N/A // Recomputing the underlying ciKlass for each request is
0N/A // a bit less efficient than caching, but calls to
0N/A // TypeAryPtr::OOPS->klass() are not common enough to matter.
0N/A ((TypeAryPtr*)this)->_klass = k_ary;
163N/A if (UseCompressedOops && k_ary != NULL && k_ary->is_obj_array_klass() &&
163N/A _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes()) {
163N/A ((TypeAryPtr*)this)->_is_ptr_to_narrowoop = true;
163N/A }
163N/A }
0N/A return k_ary;
0N/A}
0N/A
0N/A
0N/A//------------------------------add_offset-------------------------------------
0N/A// Access internals of klass object
306N/Aconst TypePtr *TypeKlassPtr::add_offset( intptr_t offset ) const {
0N/A return make( _ptr, klass(), xadd_offset(offset) );
0N/A}
0N/A
0N/A//------------------------------cast_to_ptr_type-------------------------------
0N/Aconst Type *TypeKlassPtr::cast_to_ptr_type(PTR ptr) const {
557N/A assert(_base == KlassPtr, "subclass must override cast_to_ptr_type");
0N/A if( ptr == _ptr ) return this;
0N/A return make(ptr, _klass, _offset);
0N/A}
0N/A
0N/A
0N/A//-----------------------------cast_to_exactness-------------------------------
0N/Aconst Type *TypeKlassPtr::cast_to_exactness(bool klass_is_exact) const {
0N/A if( klass_is_exact == _klass_is_exact ) return this;
0N/A if (!UseExactTypes) return this;
0N/A return make(klass_is_exact ? Constant : NotNull, _klass, _offset);
0N/A}
0N/A
0N/A
0N/A//-----------------------------as_instance_type--------------------------------
0N/A// Corresponding type for an instance of the given class.
0N/A// It will be NotNull, and exact if and only if the klass type is exact.
0N/Aconst TypeOopPtr* TypeKlassPtr::as_instance_type() const {
0N/A ciKlass* k = klass();
0N/A bool xk = klass_is_exact();
0N/A //return TypeInstPtr::make(TypePtr::NotNull, k, xk, NULL, 0);
0N/A const TypeOopPtr* toop = TypeOopPtr::make_from_klass_raw(k);
0N/A toop = toop->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
0N/A return toop->cast_to_exactness(xk)->is_oopptr();
0N/A}
0N/A
0N/A
0N/A//------------------------------xmeet------------------------------------------
0N/A// Compute the MEET of two types, return a new Type object.
0N/Aconst Type *TypeKlassPtr::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is Pointer
0N/A switch (t->base()) { // switch on original type
0N/A
0N/A case Int: // Mixing ints & oops happens when javac
0N/A case Long: // reuses local variables
0N/A case FloatTop:
0N/A case FloatCon:
0N/A case FloatBot:
0N/A case DoubleTop:
0N/A case DoubleCon:
0N/A case DoubleBot:
293N/A case NarrowOop:
0N/A case Bottom: // Ye Olde Default
0N/A return Type::BOTTOM;
0N/A case Top:
0N/A return this;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case RawPtr: return TypePtr::BOTTOM;
0N/A
0N/A case OopPtr: { // Meeting to OopPtrs
0N/A // Found a OopPtr type vs self-KlassPtr type
0N/A const TypePtr *tp = t->is_oopptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
0N/A switch (tp->ptr()) {
0N/A case TopPTR:
0N/A case AnyNull:
0N/A return make(ptr, klass(), offset);
0N/A case BotPTR:
0N/A case NotNull:
0N/A return TypePtr::make(AnyPtr, ptr, offset);
0N/A default: typerr(t);
0N/A }
0N/A }
0N/A
0N/A case AnyPtr: { // Meeting to AnyPtrs
0N/A // Found an AnyPtr type vs self-KlassPtr type
0N/A const TypePtr *tp = t->is_ptr();
0N/A int offset = meet_offset(tp->offset());
0N/A PTR ptr = meet_ptr(tp->ptr());
0N/A switch (tp->ptr()) {
0N/A case TopPTR:
0N/A return this;
0N/A case Null:
0N/A if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset );
0N/A case AnyNull:
0N/A return make( ptr, klass(), offset );
0N/A case BotPTR:
0N/A case NotNull:
0N/A return TypePtr::make(AnyPtr, ptr, offset);
0N/A default: typerr(t);
0N/A }
0N/A }
0N/A
0N/A case AryPtr: // Meet with AryPtr
0N/A case InstPtr: // Meet with InstPtr
0N/A return TypeInstPtr::BOTTOM;
0N/A
0N/A //
0N/A // A-top }
0N/A // / | \ } Tops
0N/A // B-top A-any C-top }
0N/A // | / | \ | } Any-nulls
0N/A // B-any | C-any }
0N/A // | | |
0N/A // B-con A-con C-con } constants; not comparable across classes
0N/A // | | |
0N/A // B-not | C-not }
0N/A // | \ | / | } not-nulls
0N/A // B-bot A-not C-bot }
0N/A // \ | / } Bottoms
0N/A // A-bot }
0N/A //
0N/A
0N/A case KlassPtr: { // Meet two KlassPtr types
0N/A const TypeKlassPtr *tkls = t->is_klassptr();
0N/A int off = meet_offset(tkls->offset());
0N/A PTR ptr = meet_ptr(tkls->ptr());
0N/A
0N/A // Check for easy case; klasses are equal (and perhaps not loaded!)
0N/A // If we have constants, then we created oops so classes are loaded
0N/A // and we can handle the constants further down. This case handles
0N/A // not-loaded classes
0N/A if( ptr != Constant && tkls->klass()->equals(klass()) ) {
0N/A return make( ptr, klass(), off );
0N/A }
0N/A
0N/A // Classes require inspection in the Java klass hierarchy. Must be loaded.
0N/A ciKlass* tkls_klass = tkls->klass();
0N/A ciKlass* this_klass = this->klass();
0N/A assert( tkls_klass->is_loaded(), "This class should have been loaded.");
0N/A assert( this_klass->is_loaded(), "This class should have been loaded.");
0N/A
0N/A // If 'this' type is above the centerline and is a superclass of the
0N/A // other, we can treat 'this' as having the same type as the other.
0N/A if ((above_centerline(this->ptr())) &&
0N/A tkls_klass->is_subtype_of(this_klass)) {
0N/A this_klass = tkls_klass;
0N/A }
0N/A // If 'tinst' type is above the centerline and is a superclass of the
0N/A // other, we can treat 'tinst' as having the same type as the other.
0N/A if ((above_centerline(tkls->ptr())) &&
0N/A this_klass->is_subtype_of(tkls_klass)) {
0N/A tkls_klass = this_klass;
0N/A }
0N/A
0N/A // Check for classes now being equal
0N/A if (tkls_klass->equals(this_klass)) {
0N/A // If the klasses are equal, the constants may still differ. Fall to
0N/A // NotNull if they do (neither constant is NULL; that is a special case
0N/A // handled elsewhere).
0N/A ciObject* o = NULL; // Assume not constant when done
0N/A ciObject* this_oop = const_oop();
0N/A ciObject* tkls_oop = tkls->const_oop();
0N/A if( ptr == Constant ) {
0N/A if (this_oop != NULL && tkls_oop != NULL &&
0N/A this_oop->equals(tkls_oop) )
0N/A o = this_oop;
0N/A else if (above_centerline(this->ptr()))
0N/A o = tkls_oop;
0N/A else if (above_centerline(tkls->ptr()))
0N/A o = this_oop;
0N/A else
0N/A ptr = NotNull;
0N/A }
0N/A return make( ptr, this_klass, off );
0N/A } // Else classes are not equal
0N/A
0N/A // Since klasses are different, we require the LCA in the Java
0N/A // class hierarchy - which means we have to fall to at least NotNull.
0N/A if( ptr == TopPTR || ptr == AnyNull || ptr == Constant )
0N/A ptr = NotNull;
0N/A // Now we find the LCA of Java classes
0N/A ciKlass* k = this_klass->least_common_ancestor(tkls_klass);
0N/A return make( ptr, k, off );
0N/A } // End of case KlassPtr
0N/A
0N/A } // End of switch
0N/A return this; // Return the double constant
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: compute field-by-field dual
0N/Aconst Type *TypeKlassPtr::xdual() const {
0N/A return new TypeKlassPtr( dual_ptr(), klass(), dual_offset() );
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A// Dump Klass Type
0N/A#ifndef PRODUCT
0N/Avoid TypeKlassPtr::dump2( Dict & d, uint depth, outputStream *st ) const {
0N/A switch( _ptr ) {
0N/A case Constant:
0N/A st->print("precise ");
0N/A case NotNull:
0N/A {
0N/A const char *name = klass()->name()->as_utf8();
0N/A if( name ) {
0N/A st->print("klass %s: " INTPTR_FORMAT, name, klass());
0N/A } else {
0N/A ShouldNotReachHere();
0N/A }
0N/A }
0N/A case BotPTR:
0N/A if( !WizardMode && !Verbose && !_klass_is_exact ) break;
0N/A case TopPTR:
0N/A case AnyNull:
0N/A st->print(":%s", ptr_msg[_ptr]);
0N/A if( _klass_is_exact ) st->print(":exact");
0N/A break;
0N/A }
0N/A
0N/A if( _offset ) { // Dump offset, if any
0N/A if( _offset == OffsetBot ) { st->print("+any"); }
0N/A else if( _offset == OffsetTop ) { st->print("+unknown"); }
0N/A else { st->print("+%d", _offset); }
0N/A }
0N/A
0N/A st->print(" *");
0N/A}
0N/A#endif
0N/A
0N/A
0N/A
0N/A//=============================================================================
0N/A// Convenience common pre-built types.
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeFunc *TypeFunc::make( const TypeTuple *domain, const TypeTuple *range ) {
0N/A return (TypeFunc*)(new TypeFunc(domain,range))->hashcons();
0N/A}
0N/A
0N/A//------------------------------make-------------------------------------------
0N/Aconst TypeFunc *TypeFunc::make(ciMethod* method) {
0N/A Compile* C = Compile::current();
0N/A const TypeFunc* tf = C->last_tf(method); // check cache
0N/A if (tf != NULL) return tf; // The hit rate here is almost 50%.
0N/A const TypeTuple *domain;
1137N/A if (method->is_static()) {
0N/A domain = TypeTuple::make_domain(NULL, method->signature());
0N/A } else {
0N/A domain = TypeTuple::make_domain(method->holder(), method->signature());
0N/A }
0N/A const TypeTuple *range = TypeTuple::make_range(method->signature());
0N/A tf = TypeFunc::make(domain, range);
0N/A C->set_last_tf(method, tf); // fill cache
0N/A return tf;
0N/A}
0N/A
0N/A//------------------------------meet-------------------------------------------
0N/A// Compute the MEET of two types. It returns a new Type object.
0N/Aconst Type *TypeFunc::xmeet( const Type *t ) const {
0N/A // Perform a fast test for common case; meeting the same types together.
0N/A if( this == t ) return this; // Meeting same type-rep?
0N/A
0N/A // Current "this->_base" is Func
0N/A switch (t->base()) { // switch on original type
0N/A
0N/A case Bottom: // Ye Olde Default
0N/A return t;
0N/A
0N/A default: // All else is a mistake
0N/A typerr(t);
0N/A
0N/A case Top:
0N/A break;
0N/A }
0N/A return this; // Return the double constant
0N/A}
0N/A
0N/A//------------------------------xdual------------------------------------------
0N/A// Dual: compute field-by-field dual
0N/Aconst Type *TypeFunc::xdual() const {
0N/A return this;
0N/A}
0N/A
0N/A//------------------------------eq---------------------------------------------
0N/A// Structural equality check for Type representations
0N/Abool TypeFunc::eq( const Type *t ) const {
0N/A const TypeFunc *a = (const TypeFunc*)t;
0N/A return _domain == a->_domain &&
0N/A _range == a->_range;
0N/A}
0N/A
0N/A//------------------------------hash-------------------------------------------
0N/A// Type-specific hashing function.
0N/Aint TypeFunc::hash(void) const {
0N/A return (intptr_t)_domain + (intptr_t)_range;
0N/A}
0N/A
0N/A//------------------------------dump2------------------------------------------
0N/A// Dump Function Type
0N/A#ifndef PRODUCT
0N/Avoid TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const {
0N/A if( _range->_cnt <= Parms )
0N/A st->print("void");
0N/A else {
0N/A uint i;
0N/A for (i = Parms; i < _range->_cnt-1; i++) {
0N/A _range->field_at(i)->dump2(d,depth,st);
0N/A st->print("/");
0N/A }
0N/A _range->field_at(i)->dump2(d,depth,st);
0N/A }
0N/A st->print(" ");
0N/A st->print("( ");
0N/A if( !depth || d[this] ) { // Check for recursive dump
0N/A st->print("...)");
0N/A return;
0N/A }
0N/A d.Insert((void*)this,(void*)this); // Stop recursion
0N/A if (Parms < _domain->_cnt)
0N/A _domain->field_at(Parms)->dump2(d,depth-1,st);
0N/A for (uint i = Parms+1; i < _domain->_cnt; i++) {
0N/A st->print(", ");
0N/A _domain->field_at(i)->dump2(d,depth-1,st);
0N/A }
0N/A st->print(" )");
0N/A}
0N/A
0N/A//------------------------------print_flattened--------------------------------
0N/A// Print a 'flattened' signature
0N/Astatic const char * const flat_type_msg[Type::lastype] = {
113N/A "bad","control","top","int","long","_", "narrowoop",
3845N/A "tuple:", "array:", "vectors:", "vectord:", "vectorx:", "vectory:",
0N/A "ptr", "rawptr", "ptr", "ptr", "ptr", "ptr",
0N/A "func", "abIO", "return_address", "mem",
0N/A "float_top", "ftcon:", "flt",
0N/A "double_top", "dblcon:", "dbl",
0N/A "bottom"
0N/A};
0N/A
0N/Avoid TypeFunc::print_flattened() const {
0N/A if( _range->_cnt <= Parms )
0N/A tty->print("void");
0N/A else {
0N/A uint i;
0N/A for (i = Parms; i < _range->_cnt-1; i++)
0N/A tty->print("%s/",flat_type_msg[_range->field_at(i)->base()]);
0N/A tty->print("%s",flat_type_msg[_range->field_at(i)->base()]);
0N/A }
0N/A tty->print(" ( ");
0N/A if (Parms < _domain->_cnt)
0N/A tty->print("%s",flat_type_msg[_domain->field_at(Parms)->base()]);
0N/A for (uint i = Parms+1; i < _domain->_cnt; i++)
0N/A tty->print(", %s",flat_type_msg[_domain->field_at(i)->base()]);
0N/A tty->print(" )");
0N/A}
0N/A#endif
0N/A
0N/A//------------------------------singleton--------------------------------------
0N/A// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
0N/A// constants (Ldi nodes). Singletons are integer, float or double constants
0N/A// or a single symbol.
0N/Abool TypeFunc::singleton(void) const {
0N/A return false; // Never a singleton
0N/A}
0N/A
0N/Abool TypeFunc::empty(void) const {
0N/A return false; // Never empty
0N/A}
0N/A
0N/A
0N/ABasicType TypeFunc::return_type() const{
0N/A if (range()->cnt() == TypeFunc::Parms) {
0N/A return T_VOID;
0N/A }
0N/A return range()->field_at(TypeFunc::Parms)->basic_type();
0N/A}