< prev index next >

src/hotspot/share/opto/type.cpp

Print this page
*** 21,10 ***
--- 21,13 ---
   * questions.
   *
   */
  
  #include "precompiled.hpp"
+ #include "ci/ciFlatArrayKlass.hpp"
+ #include "ci/ciField.hpp"
+ #include "ci/ciInlineKlass.hpp"
  #include "ci/ciMethodData.hpp"
  #include "ci/ciTypeFlow.hpp"
  #include "classfile/javaClasses.hpp"
  #include "classfile/symbolTable.hpp"
  #include "compiler/compileLog.hpp"

*** 46,10 ***
--- 49,56 ---
  
  // Optimization - Graph Style
  
  // Dictionary of types shared among compilations.
  Dict* Type::_shared_type_dict = NULL;
+ const Type::Offset Type::Offset::top(Type::OffsetTop);
+ const Type::Offset Type::Offset::bottom(Type::OffsetBot);
+ 
+ const Type::Offset Type::Offset::meet(const Type::Offset other) const {
+   // Either is 'TOP' offset?  Return the other offset!
+   int offset = other._offset;
+   if (_offset == OffsetTop) return Offset(offset);
+   if (offset == OffsetTop) return Offset(_offset);
+   // If either is different, return 'BOTTOM' offset
+   if (_offset != offset) return bottom;
+   return Offset(_offset);
+ }
+ 
+ const Type::Offset Type::Offset::dual() const {
+   if (_offset == OffsetTop) return bottom;// Map 'TOP' into 'BOTTOM'
+   if (_offset == OffsetBot) return top;// Map 'BOTTOM' into 'TOP'
+   return Offset(_offset);               // Map everything else into self
+ }
+ 
+ const Type::Offset Type::Offset::add(intptr_t offset) const {
+   // Adding to 'TOP' offset?  Return 'TOP'!
+   if (_offset == OffsetTop || offset == OffsetTop) return top;
+   // Adding to 'BOTTOM' offset?  Return 'BOTTOM'!
+   if (_offset == OffsetBot || offset == OffsetBot) return bottom;
+   // Addition overflows or "accidentally" equals to OffsetTop? Return 'BOTTOM'!
+   offset += (intptr_t)_offset;
+   if (offset != (int)offset || offset == OffsetTop) return bottom;
+ 
+   // assert( _offset >= 0 && _offset+offset >= 0, "" );
+   // It is possible to construct a negative offset during PhaseCCP
+ 
+   return Offset((int)offset);        // Sum valid offsets
+ }
+ 
+ void Type::Offset::dump2(outputStream *st) const {
+   if (_offset == 0) {
+     return;
+   } else if (_offset == OffsetTop) {
+     st->print("+top");
+   }
+   else if (_offset == OffsetBot) {
+     st->print("+bot");
+   } else if (_offset) {
+     st->print("+%d", _offset);
+   }
+ }
  
  // Array which maps compiler types to Basic Types
  const Type::TypeInfo Type::_type_info[Type::lastype] = {
    { Bad,             T_ILLEGAL,    "bad",           false, Node::NotAMachineReg, relocInfo::none          },  // Bad
    { Control,         T_ILLEGAL,    "control",       false, 0,                    relocInfo::none          },  // Control

*** 85,10 ***
--- 134,11 ---
    { Bad,             T_ILLEGAL,    "vectord:",      false, Op_VecD,              relocInfo::none          },  // VectorD
    { Bad,             T_ILLEGAL,    "vectorx:",      false, Op_VecX,              relocInfo::none          },  // VectorX
    { Bad,             T_ILLEGAL,    "vectory:",      false, Op_VecY,              relocInfo::none          },  // VectorY
    { Bad,             T_ILLEGAL,    "vectorz:",      false, Op_VecZ,              relocInfo::none          },  // VectorZ
  #endif
+   { Bad,             T_INLINE_TYPE, "inline:",      false, Node::NotAMachineReg, relocInfo::none          },  // InlineType
    { Bad,             T_ADDRESS,    "anyptr:",       false, Op_RegP,              relocInfo::none          },  // AnyPtr
    { Bad,             T_ADDRESS,    "rawptr:",       false, Op_RegP,              relocInfo::none          },  // RawPtr
    { Bad,             T_OBJECT,     "oop:",          true,  Op_RegP,              relocInfo::oop_type      },  // OopPtr
    { Bad,             T_OBJECT,     "inst:",         true,  Op_RegP,              relocInfo::oop_type      },  // InstPtr
    { Bad,             T_OBJECT,     "ary:",          true,  Op_RegP,              relocInfo::oop_type      },  // AryPtr

*** 217,10 ***
--- 267,20 ---
  
    case T_ADDRESS:
      assert(type->is_return_address(), "");
      return TypeRawPtr::make((address)(intptr_t)type->as_return_address()->bci());
  
+   case T_INLINE_TYPE: {
+     bool is_null_free = type->is_null_free();
+     ciInlineKlass* vk = type->unwrap()->as_inline_klass();
+     if (is_null_free) {
+       return TypeInlineType::make(vk);
+     } else {
+       return TypeOopPtr::make_from_klass(vk)->join_speculative(is_null_free ? TypePtr::NOTNULL : TypePtr::BOTTOM);
+     }
+   }
+ 
    default:
      // make sure we did not mix up the cases:
      assert(type != ciTypeFlow::StateVector::bottom_type(), "");
      assert(type != ciTypeFlow::StateVector::top_type(), "");
      assert(type != ciTypeFlow::StateVector::null_type(), "");

*** 245,10 ***
--- 305,11 ---
      case T_INT:      return TypeInt::make(constant.as_int());
      case T_LONG:     return TypeLong::make(constant.as_long());
      case T_FLOAT:    return TypeF::make(constant.as_float());
      case T_DOUBLE:   return TypeD::make(constant.as_double());
      case T_ARRAY:
+     case T_INLINE_TYPE:
      case T_OBJECT: {
          const Type* con_type = NULL;
          ciObject* oop_constant = constant.as_object();
          if (oop_constant->is_null_object()) {
            con_type = Type::get_zero_type(T_OBJECT);

*** 282,16 ***
--- 343,18 ---
  static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) {
    BasicType conbt = con.basic_type();
    switch (conbt) {
      case T_BOOLEAN: conbt = T_BYTE;   break;
      case T_ARRAY:   conbt = T_OBJECT; break;
+     case T_INLINE_TYPE: conbt = T_OBJECT; break;
      default:                          break;
    }
    switch (loadbt) {
      case T_BOOLEAN:   loadbt = T_BYTE;   break;
      case T_NARROWOOP: loadbt = T_OBJECT; break;
      case T_ARRAY:     loadbt = T_OBJECT; break;
+     case T_INLINE_TYPE: loadbt = T_OBJECT; break;
      case T_ADDRESS:   loadbt = T_OBJECT; break;
      default:                             break;
    }
    if (conbt == loadbt) {
      if (is_unsigned && conbt == T_BYTE) {

*** 523,13 ***
    const Type **floop =(const Type**)shared_type_arena->AmallocWords(2*sizeof(Type*));
    floop[0] = Type::CONTROL;
    floop[1] = TypeInt::INT;
    TypeTuple::LOOPBODY = TypeTuple::make( 2, floop );
  
!   TypePtr::NULL_PTR= TypePtr::make(AnyPtr, TypePtr::Null, 0);
!   TypePtr::NOTNULL = TypePtr::make(AnyPtr, TypePtr::NotNull, OffsetBot);
!   TypePtr::BOTTOM  = TypePtr::make(AnyPtr, TypePtr::BotPTR, OffsetBot);
  
    TypeRawPtr::BOTTOM = TypeRawPtr::make( TypePtr::BotPTR );
    TypeRawPtr::NOTNULL= TypeRawPtr::make( TypePtr::NotNull );
  
    const Type **fmembar = TypeTuple::fields(0);
--- 586,13 ---
    const Type **floop =(const Type**)shared_type_arena->AmallocWords(2*sizeof(Type*));
    floop[0] = Type::CONTROL;
    floop[1] = TypeInt::INT;
    TypeTuple::LOOPBODY = TypeTuple::make( 2, floop );
  
!   TypePtr::NULL_PTR= TypePtr::make(AnyPtr, TypePtr::Null, Offset(0));
!   TypePtr::NOTNULL = TypePtr::make(AnyPtr, TypePtr::NotNull, Offset::bottom);
!   TypePtr::BOTTOM  = TypePtr::make(AnyPtr, TypePtr::BotPTR, Offset::bottom);
  
    TypeRawPtr::BOTTOM = TypeRawPtr::make( TypePtr::BotPTR );
    TypeRawPtr::NOTNULL= TypeRawPtr::make( TypePtr::NotNull );
  
    const Type **fmembar = TypeTuple::fields(0);

*** 542,16 ***
  
    TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass());
    TypeInstPtr::BOTTOM  = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass());
    TypeInstPtr::MIRROR  = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass());
    TypeInstPtr::MARK    = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass(),
!                                            false, 0, oopDesc::mark_offset_in_bytes());
    TypeInstPtr::KLASS   = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass(),
!                                            false, 0, oopDesc::klass_offset_in_bytes());
!   TypeOopPtr::BOTTOM  = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot);
  
!   TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot);
  
    TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR );
    TypeNarrowOop::BOTTOM   = TypeNarrowOop::make( TypeInstPtr::BOTTOM );
  
    TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR );
--- 605,18 ---
  
    TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass());
    TypeInstPtr::BOTTOM  = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass());
    TypeInstPtr::MIRROR  = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass());
    TypeInstPtr::MARK    = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass(),
!                                            false, 0, Offset(oopDesc::mark_offset_in_bytes()));
    TypeInstPtr::KLASS   = TypeInstPtr::make(TypePtr::BotPTR,  current->env()->Object_klass(),
!                                            false, 0, Offset(oopDesc::klass_offset_in_bytes()));
!   TypeOopPtr::BOTTOM  = TypeOopPtr::make(TypePtr::BotPTR, Offset::bottom, TypeOopPtr::InstanceBot);
  
!   TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, Offset::bottom);
+ 
+   TypeInlineType::BOTTOM = TypeInlineType::make(NULL);
  
    TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR );
    TypeNarrowOop::BOTTOM   = TypeNarrowOop::make( TypeInstPtr::BOTTOM );
  
    TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR );

*** 564,47 ***
    mreg2type[Op_RegF] = Type::FLOAT;
    mreg2type[Op_RegD] = Type::DOUBLE;
    mreg2type[Op_RegL] = TypeLong::LONG;
    mreg2type[Op_RegFlags] = TypeInt::CC;
  
!   TypeAryPtr::RANGE   = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, arrayOopDesc::length_offset_in_bytes());
  
!   TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/,  false,  Type::OffsetBot);
  
  #ifdef _LP64
    if (UseCompressedOops) {
      assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop");
      TypeAryPtr::OOPS  = TypeAryPtr::NARROWOOPS;
    } else
  #endif
    {
      // There is no shared klass for Object[].  See note in TypeAryPtr::klass().
!     TypeAryPtr::OOPS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/,  false,  Type::OffsetBot);
    }
!   TypeAryPtr::BYTES   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE      ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE),   true,  Type::OffsetBot);
!   TypeAryPtr::SHORTS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT     ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT),  true,  Type::OffsetBot);
!   TypeAryPtr::CHARS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR      ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR),   true,  Type::OffsetBot);
!   TypeAryPtr::INTS    = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT       ,TypeInt::POS), ciTypeArrayKlass::make(T_INT),    true,  Type::OffsetBot);
!   TypeAryPtr::LONGS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG     ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG),   true,  Type::OffsetBot);
!   TypeAryPtr::FLOATS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT        ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT),  true,  Type::OffsetBot);
!   TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE       ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true,  Type::OffsetBot);
  
    // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
    TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
    TypeAryPtr::_array_body_type[T_OBJECT]  = TypeAryPtr::OOPS;
    TypeAryPtr::_array_body_type[T_ARRAY]   = TypeAryPtr::OOPS; // arrays are stored in oop arrays
    TypeAryPtr::_array_body_type[T_BYTE]    = TypeAryPtr::BYTES;
    TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES;  // boolean[] is a byte array
    TypeAryPtr::_array_body_type[T_SHORT]   = TypeAryPtr::SHORTS;
    TypeAryPtr::_array_body_type[T_CHAR]    = TypeAryPtr::CHARS;
    TypeAryPtr::_array_body_type[T_INT]     = TypeAryPtr::INTS;
    TypeAryPtr::_array_body_type[T_LONG]    = TypeAryPtr::LONGS;
    TypeAryPtr::_array_body_type[T_FLOAT]   = TypeAryPtr::FLOATS;
    TypeAryPtr::_array_body_type[T_DOUBLE]  = TypeAryPtr::DOUBLES;
  
!   TypeInstKlassPtr::OBJECT = TypeInstKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), 0);
!   TypeInstKlassPtr::OBJECT_OR_NULL = TypeInstKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), 0);
  
    const Type **fi2c = TypeTuple::fields(2);
    fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
    fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
    TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);
--- 629,49 ---
    mreg2type[Op_RegF] = Type::FLOAT;
    mreg2type[Op_RegD] = Type::DOUBLE;
    mreg2type[Op_RegL] = TypeLong::LONG;
    mreg2type[Op_RegFlags] = TypeInt::CC;
  
!   TypeAryPtr::RANGE   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, Offset(arrayOopDesc::length_offset_in_bytes()));
  
!   TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/,  false,  Offset::bottom);
  
  #ifdef _LP64
    if (UseCompressedOops) {
      assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop");
      TypeAryPtr::OOPS  = TypeAryPtr::NARROWOOPS;
    } else
  #endif
    {
      // There is no shared klass for Object[].  See note in TypeAryPtr::klass().
!     TypeAryPtr::OOPS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/,  false,  Offset::bottom);
    }
!   TypeAryPtr::BYTES   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE      ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE),   true,  Offset::bottom);
!   TypeAryPtr::SHORTS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT     ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT),  true,  Offset::bottom);
!   TypeAryPtr::CHARS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR      ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR),   true,  Offset::bottom);
!   TypeAryPtr::INTS    = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT       ,TypeInt::POS), ciTypeArrayKlass::make(T_INT),    true,  Offset::bottom);
!   TypeAryPtr::LONGS   = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG     ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG),   true,  Offset::bottom);
!   TypeAryPtr::FLOATS  = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT        ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT),  true,  Offset::bottom);
!   TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE       ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true,  Offset::bottom);
+   TypeAryPtr::INLINES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInlineType::BOTTOM,TypeInt::POS), NULL, false,  Offset::bottom);
  
    // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
    TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
    TypeAryPtr::_array_body_type[T_OBJECT]  = TypeAryPtr::OOPS;
+   TypeAryPtr::_array_body_type[T_INLINE_TYPE] = TypeAryPtr::OOPS;
    TypeAryPtr::_array_body_type[T_ARRAY]   = TypeAryPtr::OOPS; // arrays are stored in oop arrays
    TypeAryPtr::_array_body_type[T_BYTE]    = TypeAryPtr::BYTES;
    TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES;  // boolean[] is a byte array
    TypeAryPtr::_array_body_type[T_SHORT]   = TypeAryPtr::SHORTS;
    TypeAryPtr::_array_body_type[T_CHAR]    = TypeAryPtr::CHARS;
    TypeAryPtr::_array_body_type[T_INT]     = TypeAryPtr::INTS;
    TypeAryPtr::_array_body_type[T_LONG]    = TypeAryPtr::LONGS;
    TypeAryPtr::_array_body_type[T_FLOAT]   = TypeAryPtr::FLOATS;
    TypeAryPtr::_array_body_type[T_DOUBLE]  = TypeAryPtr::DOUBLES;
  
!   TypeInstKlassPtr::OBJECT = TypeInstKlassPtr::make(TypePtr::NotNull, current->env()->Object_klass(), Offset(0), false);
!   TypeInstKlassPtr::OBJECT_OR_NULL = TypeInstKlassPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), Offset(0), false);
  
    const Type **fi2c = TypeTuple::fields(2);
    fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
    fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
    TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);

*** 639,10 ***
--- 706,11 ---
    _const_basic_type[T_LONG]        = TypeLong::LONG;
    _const_basic_type[T_FLOAT]       = Type::FLOAT;
    _const_basic_type[T_DOUBLE]      = Type::DOUBLE;
    _const_basic_type[T_OBJECT]      = TypeInstPtr::BOTTOM;
    _const_basic_type[T_ARRAY]       = TypeInstPtr::BOTTOM; // there is no separate bottom for arrays
+   _const_basic_type[T_INLINE_TYPE] = TypeInstPtr::BOTTOM;
    _const_basic_type[T_VOID]        = TypePtr::NULL_PTR;   // reflection represents void this way
    _const_basic_type[T_ADDRESS]     = TypeRawPtr::BOTTOM;  // both interpreter return addresses & random raw ptrs
    _const_basic_type[T_CONFLICT]    = Type::BOTTOM;        // why not?
  
    _zero_type[T_NARROWOOP]   = TypeNarrowOop::NULL_PTR;

*** 655,10 ***
--- 723,11 ---
    _zero_type[T_LONG]        = TypeLong::ZERO;
    _zero_type[T_FLOAT]       = TypeF::ZERO;
    _zero_type[T_DOUBLE]      = TypeD::ZERO;
    _zero_type[T_OBJECT]      = TypePtr::NULL_PTR;
    _zero_type[T_ARRAY]       = TypePtr::NULL_PTR; // null array is null oop
+   _zero_type[T_INLINE_TYPE] = TypePtr::NULL_PTR;
    _zero_type[T_ADDRESS]     = TypePtr::NULL_PTR; // raw pointers use the same null
    _zero_type[T_VOID]        = Type::TOP;         // the only void value is no value at all
  
    // get_zero_type() should not happen for T_CONFLICT
    _zero_type[T_CONFLICT]= NULL;

*** 946,10 ***
--- 1015,13 ---
      return t->xmeet(this);
  
    case NarrowKlass:
      return t->xmeet(this);
  
+   case InlineType:
+     return t->xmeet(this);
+ 
    case Bad:                     // Type check
    default:                      // Bogus type not in lattice
      typerr(t);
      return Type::BOTTOM;
  

*** 1116,10 ***
--- 1188,11 ---
      case Type::FloatCon:
      case Type::FloatBot:
      case Type::DoubleTop:
      case Type::DoubleCon:
      case Type::DoubleBot:
+     case Type::InlineType:
        return Category::Data;
      case Type::Memory:
        return Category::Memory;
      case Type::Control:
        return Category::Control;

*** 1491,10 ***
--- 1564,11 ---
    case FloatCon:
    case FloatBot:
    case DoubleTop:
    case DoubleCon:
    case DoubleBot:
+   case InlineType:
    case Bottom:                  // Ye Olde Default
      return Type::BOTTOM;
    default:                      // All else is a mistake
      typerr(t);
    case Top:                     // No change

*** 1978,15 ***
  const TypeTuple *TypeTuple::INT_PAIR;
  const TypeTuple *TypeTuple::LONG_PAIR;
  const TypeTuple *TypeTuple::INT_CC_PAIR;
  const TypeTuple *TypeTuple::LONG_CC_PAIR;
  
  //------------------------------make-------------------------------------------
  // Make a TypeTuple from the range of a method signature
! const TypeTuple *TypeTuple::make_range(ciSignature* sig) {
    ciType* return_type = sig->return_type();
    uint arg_cnt = return_type->size();
    const Type **field_array = fields(arg_cnt);
    switch (return_type->basic_type()) {
    case T_LONG:
      field_array[TypeFunc::Parms]   = TypeLong::LONG;
      field_array[TypeFunc::Parms+1] = Type::HALF;
--- 2052,31 ---
  const TypeTuple *TypeTuple::INT_PAIR;
  const TypeTuple *TypeTuple::LONG_PAIR;
  const TypeTuple *TypeTuple::INT_CC_PAIR;
  const TypeTuple *TypeTuple::LONG_CC_PAIR;
  
+ static void collect_inline_fields(ciInlineKlass* vk, const Type** field_array, uint& pos) {
+   for (int j = 0; j < vk->nof_nonstatic_fields(); j++) {
+     ciField* field = vk->nonstatic_field_at(j);
+     BasicType bt = field->type()->basic_type();
+     const Type* ft = Type::get_const_type(field->type());
+     field_array[pos++] = ft;
+     if (type2size[bt] == 2) {
+       field_array[pos++] = Type::HALF;
+     }
+   }
+ }
+ 
  //------------------------------make-------------------------------------------
  // Make a TypeTuple from the range of a method signature
! const TypeTuple *TypeTuple::make_range(ciSignature* sig, bool ret_vt_fields) {
    ciType* return_type = sig->return_type();
    uint arg_cnt = return_type->size();
+   if (ret_vt_fields) {
+     arg_cnt = return_type->as_inline_klass()->inline_arg_slots() + 1;
+   }
+ 
    const Type **field_array = fields(arg_cnt);
    switch (return_type->basic_type()) {
    case T_LONG:
      field_array[TypeFunc::Parms]   = TypeLong::LONG;
      field_array[TypeFunc::Parms+1] = Type::HALF;

*** 2003,38 ***
    case T_BYTE:
    case T_SHORT:
    case T_INT:
      field_array[TypeFunc::Parms] = get_const_type(return_type);
      break;
    case T_VOID:
      break;
    default:
      ShouldNotReachHere();
    }
    return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons();
  }
  
  // Make a TypeTuple from the domain of a method signature
! const TypeTuple *TypeTuple::make_domain(ciInstanceKlass* recv, ciSignature* sig) {
!   uint arg_cnt = sig->size();
  
    uint pos = TypeFunc::Parms;
!   const Type **field_array;
!   if (recv != NULL) {
!     arg_cnt++;
!     field_array = fields(arg_cnt);
!     // Use get_const_type here because it respects UseUniqueSubclasses:
!     field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL);
!   } else {
!     field_array = fields(arg_cnt);
    }
  
    int i = 0;
    while (pos < TypeFunc::Parms + arg_cnt) {
      ciType* type = sig->type_at(i);
  
!     switch (type->basic_type()) {
      case T_LONG:
        field_array[pos++] = TypeLong::LONG;
        field_array[pos++] = Type::HALF;
        break;
      case T_DOUBLE:
--- 2093,55 ---
    case T_BYTE:
    case T_SHORT:
    case T_INT:
      field_array[TypeFunc::Parms] = get_const_type(return_type);
      break;
+   case T_INLINE_TYPE:
+     if (ret_vt_fields) {
+       uint pos = TypeFunc::Parms;
+       field_array[pos++] = get_const_type(return_type); // Oop might be null when returning as fields
+       collect_inline_fields(return_type->as_inline_klass(), field_array, pos);
+     } else {
+       field_array[TypeFunc::Parms] = get_const_type(return_type)->join_speculative(sig->returns_null_free_inline_type() ? TypePtr::NOTNULL : TypePtr::BOTTOM);
+     }
+     break;
    case T_VOID:
      break;
    default:
      ShouldNotReachHere();
    }
    return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons();
  }
  
  // Make a TypeTuple from the domain of a method signature
! const TypeTuple *TypeTuple::make_domain(ciMethod* method, bool vt_fields_as_args) {
!   ciSignature* sig = method->signature();
+   uint arg_cnt = sig->size() + (method->is_static() ? 0 : 1);
+   if (vt_fields_as_args) {
+     arg_cnt = 0;
+     for (ExtendedSignature sig_cc = ExtendedSignature(method->get_sig_cc(), SigEntryFilter()); !sig_cc.at_end(); ++sig_cc) {
+       arg_cnt += type2size[(*sig_cc)._bt];
+     }
+   }
  
    uint pos = TypeFunc::Parms;
!   const Type** field_array = fields(arg_cnt);
!   if (!method->is_static()) {
!     ciInstanceKlass* recv = method->holder();
!     if (vt_fields_as_args && recv->is_inlinetype() && recv->as_inline_klass()->can_be_passed_as_fields()) {
!       collect_inline_fields(recv->as_inline_klass(), field_array, pos);
!     } else {
!       field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL);
!     }
    }
  
    int i = 0;
    while (pos < TypeFunc::Parms + arg_cnt) {
      ciType* type = sig->type_at(i);
+     BasicType bt = type->basic_type();
  
!     switch (bt) {
      case T_LONG:
        field_array[pos++] = TypeLong::LONG;
        field_array[pos++] = Type::HALF;
        break;
      case T_DOUBLE:

*** 2051,15 ***
--- 2158,25 ---
      case T_CHAR:
      case T_BYTE:
      case T_SHORT:
        field_array[pos++] = TypeInt::INT;
        break;
+     case T_INLINE_TYPE: {
+       bool is_null_free = sig->is_null_free_at(i);
+       if (vt_fields_as_args && type->as_inline_klass()->can_be_passed_as_fields() && is_null_free) {
+         collect_inline_fields(type->as_inline_klass(), field_array, pos);
+       } else {
+         field_array[pos++] = get_const_type(type)->join_speculative(is_null_free ? TypePtr::NOTNULL : TypePtr::BOTTOM);
+       }
+       break;
+     }
      default:
        ShouldNotReachHere();
      }
      i++;
    }
+   assert(pos == TypeFunc::Parms + arg_cnt, "wrong number of arguments");
  
    return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons();
  }
  
  const TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) {

*** 2190,16 ***
    else
      return size;
  }
  
  //------------------------------make-------------------------------------------
! const TypeAry* TypeAry::make(const Type* elem, const TypeInt* size, bool stable) {
    if (UseCompressedOops && elem->isa_oopptr()) {
      elem = elem->make_narrowoop();
    }
    size = normalize_array_size(size);
!   return (TypeAry*)(new TypeAry(elem,size,stable))->hashcons();
  }
  
  //------------------------------meet-------------------------------------------
  // Compute the MEET of two types.  It returns a new Type object.
  const Type *TypeAry::xmeet( const Type *t ) const {
--- 2307,17 ---
    else
      return size;
  }
  
  //------------------------------make-------------------------------------------
! const TypeAry* TypeAry::make(const Type* elem, const TypeInt* size, bool stable,
+                              bool not_flat, bool not_null_free) {
    if (UseCompressedOops && elem->isa_oopptr()) {
      elem = elem->make_narrowoop();
    }
    size = normalize_array_size(size);
!   return (TypeAry*)(new TypeAry(elem, size, stable, not_flat, not_null_free))->hashcons();
  }
  
  //------------------------------meet-------------------------------------------
  // Compute the MEET of two types.  It returns a new Type object.
  const Type *TypeAry::xmeet( const Type *t ) const {

*** 2217,11 ***
  
    case Array: {                 // Meeting 2 arrays?
      const TypeAry *a = t->is_ary();
      return TypeAry::make(_elem->meet_speculative(a->_elem),
                           _size->xmeet(a->_size)->is_int(),
!                          _stable && a->_stable);
    }
    case Top:
      break;
    }
    return this;                  // Return the double constant
--- 2335,13 ---
  
    case Array: {                 // Meeting 2 arrays?
      const TypeAry *a = t->is_ary();
      return TypeAry::make(_elem->meet_speculative(a->_elem),
                           _size->xmeet(a->_size)->is_int(),
!                          _stable && a->_stable,
+                          _not_flat && a->_not_flat,
+                          _not_null_free && a->_not_null_free);
    }
    case Top:
      break;
    }
    return this;                  // Return the double constant

*** 2230,20 ***
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const Type *TypeAry::xdual() const {
    const TypeInt* size_dual = _size->dual()->is_int();
    size_dual = normalize_array_size(size_dual);
!   return new TypeAry(_elem->dual(), size_dual, !_stable);
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeAry::eq( const Type *t ) const {
    const TypeAry *a = (const TypeAry*)t;
    return _elem == a->_elem &&
      _stable == a->_stable &&
!     _size == a->_size;
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeAry::hash(void) const {
--- 2350,23 ---
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const Type *TypeAry::xdual() const {
    const TypeInt* size_dual = _size->dual()->is_int();
    size_dual = normalize_array_size(size_dual);
!   return new TypeAry(_elem->dual(), size_dual, !_stable, !_not_flat, !_not_null_free);
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeAry::eq( const Type *t ) const {
    const TypeAry *a = (const TypeAry*)t;
    return _elem == a->_elem &&
      _stable == a->_stable &&
!     _size == a->_size &&
+     _not_flat == a->_not_flat &&
+     _not_null_free == a->_not_null_free;
+ 
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeAry::hash(void) const {

*** 2252,18 ***
  
  /**
   * Return same type without a speculative part in the element
   */
  const Type* TypeAry::remove_speculative() const {
!   return make(_elem->remove_speculative(), _size, _stable);
  }
  
  /**
   * Return same type with cleaned up speculative part of element
   */
  const Type* TypeAry::cleanup_speculative() const {
!   return make(_elem->cleanup_speculative(), _size, _stable);
  }
  
  /**
   * Return same type but with a different inline depth (used for speculation)
   *
--- 2375,18 ---
  
  /**
   * Return same type without a speculative part in the element
   */
  const Type* TypeAry::remove_speculative() const {
!   return make(_elem->remove_speculative(), _size, _stable, _not_flat, _not_null_free);
  }
  
  /**
   * Return same type with cleaned up speculative part of element
   */
  const Type* TypeAry::cleanup_speculative() const {
!   return make(_elem->cleanup_speculative(), _size, _stable, _not_flat, _not_null_free);
  }
  
  /**
   * Return same type but with a different inline depth (used for speculation)
   *

*** 2293,10 ***
--- 2416,14 ---
  
  //------------------------------dump2------------------------------------------
  #ifndef PRODUCT
  void TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const {
    if (_stable)  st->print("stable:");
+   if (Verbose) {
+     if (_not_flat) st->print("not flat:");
+     if (_not_null_free) st->print("not null free:");
+   }
    _elem->dump2(d, depth, st);
    st->print("[");
    _size->dump2(d, depth, st);
    st->print("]");
  }

*** 2334,22 ***
    const TypeInstPtr* tinst;
    if (_elem->isa_narrowoop())
      tinst = _elem->make_ptr()->isa_instptr();
    else
      tinst = _elem->isa_instptr();
!   if (tinst)
!     return tklass->as_instance_klass()->is_final();
    const TypeAryPtr*  tap;
    if (_elem->isa_narrowoop())
      tap = _elem->make_ptr()->isa_aryptr();
    else
      tap = _elem->isa_aryptr();
    if (tap)
      return tap->ary()->ary_must_be_exact();
    return false;
  }
  
  //==============================TypeVect=======================================
  // Convenience common pre-built types.
  const TypeVect *TypeVect::VECTA = NULL; // vector length agnostic
  const TypeVect *TypeVect::VECTS = NULL; //  32-bit vectors
  const TypeVect *TypeVect::VECTD = NULL; //  64-bit vectors
--- 2461,157 ---
    const TypeInstPtr* tinst;
    if (_elem->isa_narrowoop())
      tinst = _elem->make_ptr()->isa_instptr();
    else
      tinst = _elem->isa_instptr();
!   if (tinst) {
!     if (tklass->as_instance_klass()->is_final()) {
+       // Even if MyValue is exact, [LMyValue is not exact due to [QMyValue <: [LMyValue.
+       if (tinst->is_inlinetypeptr() && (tinst->ptr() == TypePtr::BotPTR || tinst->ptr() == TypePtr::TopPTR)) {
+         return false;
+       }
+       return true;
+     }
+     return false;
+   }
    const TypeAryPtr*  tap;
    if (_elem->isa_narrowoop())
      tap = _elem->make_ptr()->isa_aryptr();
    else
      tap = _elem->isa_aryptr();
    if (tap)
      return tap->ary()->ary_must_be_exact();
    return false;
  }
  
+ //==============================TypeInlineType=======================================
+ 
+ const TypeInlineType* TypeInlineType::BOTTOM;
+ 
+ //------------------------------make-------------------------------------------
+ const TypeInlineType* TypeInlineType::make(ciInlineKlass* vk, bool larval) {
+   return (TypeInlineType*)(new TypeInlineType(vk, larval))->hashcons();
+ }
+ 
+ //------------------------------meet-------------------------------------------
+ // Compute the MEET of two types.  It returns a new Type object.
+ const Type* TypeInlineType::xmeet(const Type* t) const {
+   // Perform a fast test for common case; meeting the same types together.
+   if(this == t) return this;  // Meeting same type-rep?
+ 
+   // Current "this->_base" is InlineType
+   switch (t->base()) {          // switch on original type
+ 
+   case Int:
+   case Long:
+   case FloatTop:
+   case FloatCon:
+   case FloatBot:
+   case DoubleTop:
+   case DoubleCon:
+   case DoubleBot:
+   case NarrowKlass:
+   case Bottom:
+     return Type::BOTTOM;
+ 
+   case OopPtr:
+   case MetadataPtr:
+   case KlassPtr:
+   case RawPtr:
+   case AnyPtr:
+     return TypePtr::BOTTOM;
+ 
+   case Top:
+     return this;
+ 
+   case NarrowOop: {
+     const Type* res = t->make_ptr()->xmeet(this);
+     if (res->isa_ptr()) {
+       return res->make_narrowoop();
+     }
+     return res;
+   }
+ 
+   case InstKlassPtr:
+   case AryKlassPtr:
+   case AryPtr:
+   case InstPtr: {
+     return t->xmeet(this);
+   }
+ 
+   case InlineType: {
+     // All inline types inherit from Object
+     const TypeInlineType* other = t->is_inlinetype();
+     if (_vk == NULL) {
+       return this;
+     } else if (other->_vk == NULL) {
+       return other;
+     } else if (_vk == other->_vk) {
+       if (_larval == other->_larval ||
+           !_larval) {
+         return this;
+       } else {
+         return t;
+       }
+     }
+     return TypeInstPtr::NOTNULL;
+   }
+ 
+   default:                      // All else is a mistake
+     typerr(t);
+ 
+   }
+   return this;
+ }
+ 
+ //------------------------------xdual------------------------------------------
+ const Type* TypeInlineType::xdual() const {
+   return this;
+ }
+ 
+ //------------------------------eq---------------------------------------------
+ // Structural equality check for Type representations
+ bool TypeInlineType::eq(const Type* t) const {
+   const TypeInlineType* vt = t->is_inlinetype();
+   return (_vk == vt->inline_klass() && _larval == vt->larval());
+ }
+ 
+ //------------------------------hash-------------------------------------------
+ // Type-specific hashing function.
+ int TypeInlineType::hash(void) const {
+   return (intptr_t)_vk;
+ }
+ 
+ //------------------------------singleton--------------------------------------
+ // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple constants.
+ bool TypeInlineType::singleton(void) const {
+   return false;
+ }
+ 
+ //------------------------------empty------------------------------------------
+ // TRUE if Type is a type with no values, FALSE otherwise.
+ bool TypeInlineType::empty(void) const {
+   return false;
+ }
+ 
+ //------------------------------dump2------------------------------------------
+ #ifndef PRODUCT
+ void TypeInlineType::dump2(Dict &d, uint depth, outputStream* st) const {
+   if (_vk == NULL) {
+     st->print("BOTTOM inlinetype");
+     return;
+   }
+   int count = _vk->nof_declared_nonstatic_fields();
+   st->print("inlinetype[%d]:{", count);
+   st->print("%s", count != 0 ? _vk->declared_nonstatic_field_at(0)->type()->name() : "empty");
+   for (int i = 1; i < count; ++i) {
+     st->print(", %s", _vk->declared_nonstatic_field_at(i)->type()->name());
+   }
+   st->print("}%s", _larval?" : larval":"");
+ }
+ #endif
+ 
  //==============================TypeVect=======================================
  // Convenience common pre-built types.
  const TypeVect *TypeVect::VECTA = NULL; // vector length agnostic
  const TypeVect *TypeVect::VECTS = NULL; //  32-bit vectors
  const TypeVect *TypeVect::VECTD = NULL; //  64-bit vectors

*** 2518,11 ***
    { /* NotNull */ NotNull,   NotNull,   NotNull,  BotPTR, NotNull, BotPTR,},
    { /* BotPTR  */ BotPTR,    BotPTR,    BotPTR,   BotPTR, BotPTR,  BotPTR,}
  };
  
  //------------------------------make-------------------------------------------
! const TypePtr *TypePtr::make(TYPES t, enum PTR ptr, int offset, const TypePtr* speculative, int inline_depth) {
    return (TypePtr*)(new TypePtr(t,ptr,offset, speculative, inline_depth))->hashcons();
  }
  
  //------------------------------cast_to_ptr_type-------------------------------
  const Type *TypePtr::cast_to_ptr_type(PTR ptr) const {
--- 2780,11 ---
    { /* NotNull */ NotNull,   NotNull,   NotNull,  BotPTR, NotNull, BotPTR,},
    { /* BotPTR  */ BotPTR,    BotPTR,    BotPTR,   BotPTR, BotPTR,  BotPTR,}
  };
  
  //------------------------------make-------------------------------------------
! const TypePtr* TypePtr::make(TYPES t, enum PTR ptr, Offset offset, const TypePtr* speculative, int inline_depth) {
    return (TypePtr*)(new TypePtr(t,ptr,offset, speculative, inline_depth))->hashcons();
  }
  
  //------------------------------cast_to_ptr_type-------------------------------
  const Type *TypePtr::cast_to_ptr_type(PTR ptr) const {

*** 2532,11 ***
  }
  
  //------------------------------get_con----------------------------------------
  intptr_t TypePtr::get_con() const {
    assert( _ptr == Null, "" );
!   return _offset;
  }
  
  //------------------------------meet-------------------------------------------
  // Compute the MEET of two types.  It returns a new Type object.
  const Type *TypePtr::xmeet(const Type *t) const {
--- 2794,11 ---
  }
  
  //------------------------------get_con----------------------------------------
  intptr_t TypePtr::get_con() const {
    assert( _ptr == Null, "" );
!   return offset();
  }
  
  //------------------------------meet-------------------------------------------
  // Compute the MEET of two types.  It returns a new Type object.
  const Type *TypePtr::xmeet(const Type *t) const {

*** 2594,33 ***
    case AryPtr:
    case MetadataPtr:
    case KlassPtr:
    case InstKlassPtr:
    case AryKlassPtr:
      return t->xmeet(this);      // Call in reverse direction
    default:                      // All else is a mistake
      typerr(t);
  
    }
    return this;
  }
  
  //------------------------------meet_offset------------------------------------
! int TypePtr::meet_offset( int offset ) const {
!   // Either is 'TOP' offset?  Return the other offset!
-   if( _offset == OffsetTop ) return offset;
-   if( offset == OffsetTop ) return _offset;
-   // If either is different, return 'BOTTOM' offset
-   if( _offset != offset ) return OffsetBot;
-   return _offset;
  }
  
  //------------------------------dual_offset------------------------------------
! int TypePtr::dual_offset( ) const {
!   if( _offset == OffsetTop ) return OffsetBot;// Map 'TOP' into 'BOTTOM'
-   if( _offset == OffsetBot ) return OffsetTop;// Map 'BOTTOM' into 'TOP'
-   return _offset;               // Map everything else into self
  }
  
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const TypePtr::PTR TypePtr::ptr_dual[TypePtr::lastPTR] = {
--- 2856,27 ---
    case AryPtr:
    case MetadataPtr:
    case KlassPtr:
    case InstKlassPtr:
    case AryKlassPtr:
+   case InlineType:
      return t->xmeet(this);      // Call in reverse direction
    default:                      // All else is a mistake
      typerr(t);
  
    }
    return this;
  }
  
  //------------------------------meet_offset------------------------------------
! Type::Offset TypePtr::meet_offset(int offset) const {
!   return _offset.meet(Offset(offset));
  }
  
  //------------------------------dual_offset------------------------------------
! Type::Offset TypePtr::dual_offset() const {
!   return _offset.dual();
  }
  
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const TypePtr::PTR TypePtr::ptr_dual[TypePtr::lastPTR] = {

*** 2629,23 ***
  const Type *TypePtr::xdual() const {
    return new TypePtr(AnyPtr, dual_ptr(), dual_offset(), dual_speculative(), dual_inline_depth());
  }
  
  //------------------------------xadd_offset------------------------------------
! int TypePtr::xadd_offset( intptr_t offset ) const {
!   // Adding to 'TOP' offset?  Return 'TOP'!
-   if( _offset == OffsetTop || offset == OffsetTop ) return OffsetTop;
-   // Adding to 'BOTTOM' offset?  Return 'BOTTOM'!
-   if( _offset == OffsetBot || offset == OffsetBot ) return OffsetBot;
-   // Addition overflows or "accidentally" equals to OffsetTop? Return 'BOTTOM'!
-   offset += (intptr_t)_offset;
-   if (offset != (int)offset || offset == OffsetTop) return OffsetBot;
- 
-   // assert( _offset >= 0 && _offset+offset >= 0, "" );
-   // It is possible to construct a negative offset during PhaseCCP
- 
-   return (int)offset;        // Sum valid offsets
  }
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypePtr::add_offset( intptr_t offset ) const {
    return make(AnyPtr, _ptr, xadd_offset(offset), _speculative, _inline_depth);
--- 2885,12 ---
  const Type *TypePtr::xdual() const {
    return new TypePtr(AnyPtr, dual_ptr(), dual_offset(), dual_speculative(), dual_inline_depth());
  }
  
  //------------------------------xadd_offset------------------------------------
! Type::Offset TypePtr::xadd_offset(intptr_t offset) const {
!   return _offset.add(offset);
  }
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypePtr::add_offset( intptr_t offset ) const {
    return make(AnyPtr, _ptr, xadd_offset(offset), _speculative, _inline_depth);

*** 2653,17 ***
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypePtr::eq( const Type *t ) const {
    const TypePtr *a = (const TypePtr*)t;
!   return _ptr == a->ptr() && _offset == a->offset() && eq_speculative(a) && _inline_depth == a->_inline_depth;
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypePtr::hash(void) const {
!   return java_add(java_add((jint)_ptr, (jint)_offset), java_add((jint)hash_speculative(), (jint)_inline_depth));
  ;
  }
  
  /**
   * Return same type without a speculative part
--- 2898,17 ---
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypePtr::eq( const Type *t ) const {
    const TypePtr *a = (const TypePtr*)t;
!   return _ptr == a->ptr() && _offset == a->_offset && eq_speculative(a) && _inline_depth == a->_inline_depth;
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypePtr::hash(void) const {
!   return java_add(java_add((jint)_ptr, (jint)offset()), java_add((jint)hash_speculative(), (jint)_inline_depth));
  ;
  }
  
  /**
   * Return same type without a speculative part

*** 2919,13 ***
  
  #ifndef PRODUCT
  void TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const {
    if( _ptr == Null ) st->print("NULL");
    else st->print("%s *", ptr_msg[_ptr]);
!   if( _offset == OffsetTop ) st->print("+top");
-   else if( _offset == OffsetBot ) st->print("+bot");
-   else if( _offset ) st->print("+%d", _offset);
    dump_inline_depth(st);
    dump_speculative(st);
  }
  
  /**
--- 3164,11 ---
  
  #ifndef PRODUCT
  void TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const {
    if( _ptr == Null ) st->print("NULL");
    else st->print("%s *", ptr_msg[_ptr]);
!   _offset.dump2(st);
    dump_inline_depth(st);
    dump_speculative(st);
  }
  
  /**

*** 2956,15 ***
  //------------------------------singleton--------------------------------------
  // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  // constants
  bool TypePtr::singleton(void) const {
    // TopPTR, Null, AnyNull, Constant are all singletons
!   return (_offset != OffsetBot) && !below_centerline(_ptr);
  }
  
  bool TypePtr::empty(void) const {
!   return (_offset == OffsetTop) || above_centerline(_ptr);
  }
  
  //=============================================================================
  // Convenience common pre-built types.
  const TypeRawPtr *TypeRawPtr::BOTTOM;
--- 3199,15 ---
  //------------------------------singleton--------------------------------------
  // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  // constants
  bool TypePtr::singleton(void) const {
    // TopPTR, Null, AnyNull, Constant are all singletons
!   return (_offset != Offset::bottom) && !below_centerline(_ptr);
  }
  
  bool TypePtr::empty(void) const {
!   return (_offset == Offset::top) || above_centerline(_ptr);
  }
  
  //=============================================================================
  // Convenience common pre-built types.
  const TypeRawPtr *TypeRawPtr::BOTTOM;

*** 3104,69 ***
  //=============================================================================
  // Convenience common pre-built type.
  const TypeOopPtr *TypeOopPtr::BOTTOM;
  
  //------------------------------TypeOopPtr-------------------------------------
! TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset,
                         int instance_id, const TypePtr* speculative, int inline_depth)
    : TypePtr(t, ptr, offset, speculative, inline_depth),
      _const_oop(o), _klass(k),
      _klass_is_exact(xk),
      _is_ptr_to_narrowoop(false),
      _is_ptr_to_narrowklass(false),
      _is_ptr_to_boxed_value(false),
      _instance_id(instance_id) {
    if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
!       (offset > 0) && xk && (k != 0) && k->is_instance_klass()) {
!     _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset);
    }
  #ifdef _LP64
!   if (_offset > 0 || _offset == Type::OffsetTop || _offset == Type::OffsetBot) {
!     if (_offset == oopDesc::klass_offset_in_bytes()) {
        _is_ptr_to_narrowklass = UseCompressedClassPointers;
      } else if (klass() == NULL) {
        // Array with unknown body type
        assert(this->isa_aryptr(), "only arrays without klass");
        _is_ptr_to_narrowoop = UseCompressedOops;
!     } else if (this->isa_aryptr()) {
!       _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() &&
!                              _offset != arrayOopDesc::length_offset_in_bytes());
      } else if (klass()->is_instance_klass()) {
-       ciInstanceKlass* ik = klass()->as_instance_klass();
-       ciField* field = NULL;
        if (this->isa_klassptr()) {
          // Perm objects don't use compressed references
!       } else if (_offset == OffsetBot || _offset == OffsetTop) {
          // unsafe access
          _is_ptr_to_narrowoop = UseCompressedOops;
        } else {
          assert(this->isa_instptr(), "must be an instance ptr.");
- 
          if (klass() == ciEnv::current()->Class_klass() &&
!             (_offset == java_lang_Class::klass_offset() ||
!              _offset == java_lang_Class::array_klass_offset())) {
            // Special hidden fields from the Class.
            assert(this->isa_instptr(), "must be an instance ptr.");
            _is_ptr_to_narrowoop = false;
          } else if (klass() == ciEnv::current()->Class_klass() &&
!                    _offset >= InstanceMirrorKlass::offset_of_static_fields()) {
            // Static fields
            ciField* field = NULL;
            if (const_oop() != NULL) {
              ciInstanceKlass* k = const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass();
!             field = k->get_field_by_offset(_offset, true);
!           }
!           if (field != NULL) {
!             BasicType basic_elem_type = field->layout_type();
!             _is_ptr_to_narrowoop = UseCompressedOops && is_reference_type(basic_elem_type);
!           } else {
!             // unsafe access
!             _is_ptr_to_narrowoop = UseCompressedOops;
            }
          } else {
            // Instance fields which contains a compressed oop references.
!           field = ik->get_field_by_offset(_offset, false);
            if (field != NULL) {
              BasicType basic_elem_type = field->layout_type();
              _is_ptr_to_narrowoop = UseCompressedOops && is_reference_type(basic_elem_type);
            } else if (klass()->equals(ciEnv::current()->Object_klass())) {
              // Compile::find_alias_type() cast exactness on all types to verify
--- 3347,82 ---
  //=============================================================================
  // Convenience common pre-built type.
  const TypeOopPtr *TypeOopPtr::BOTTOM;
  
  //------------------------------TypeOopPtr-------------------------------------
! TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, Offset field_offset,
                         int instance_id, const TypePtr* speculative, int inline_depth)
    : TypePtr(t, ptr, offset, speculative, inline_depth),
      _const_oop(o), _klass(k),
      _klass_is_exact(xk),
      _is_ptr_to_narrowoop(false),
      _is_ptr_to_narrowklass(false),
      _is_ptr_to_boxed_value(false),
      _instance_id(instance_id) {
    if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
!       (offset.get() > 0) && xk && (k != 0) && k->is_instance_klass()) {
!     _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset.get());
    }
  #ifdef _LP64
!   if (this->offset() > 0 || this->offset() == Type::OffsetTop || this->offset() == Type::OffsetBot) {
!     if (this->offset() == oopDesc::klass_offset_in_bytes()) {
        _is_ptr_to_narrowklass = UseCompressedClassPointers;
      } else if (klass() == NULL) {
        // Array with unknown body type
        assert(this->isa_aryptr(), "only arrays without klass");
        _is_ptr_to_narrowoop = UseCompressedOops;
!     } else if (UseCompressedOops && this->isa_aryptr() && this->offset() != arrayOopDesc::length_offset_in_bytes()) {
!       if (klass()->is_obj_array_klass()) {
!         _is_ptr_to_narrowoop = true;
+       } else if (klass()->is_flat_array_klass() && field_offset != Offset::top && field_offset != Offset::bottom) {
+         // Check if the field of the inline type array element contains oops
+         ciInlineKlass* vk = klass()->as_flat_array_klass()->element_klass()->as_inline_klass();
+         int foffset = field_offset.get() + vk->first_field_offset();
+         ciField* field = vk->get_field_by_offset(foffset, false);
+         assert(field != NULL, "missing field");
+         BasicType bt = field->layout_type();
+         _is_ptr_to_narrowoop = UseCompressedOops && is_reference_type(bt);
+       }
      } else if (klass()->is_instance_klass()) {
        if (this->isa_klassptr()) {
          // Perm objects don't use compressed references
!       } else if (_offset == Offset::bottom || _offset == Offset::top) {
          // unsafe access
          _is_ptr_to_narrowoop = UseCompressedOops;
        } else {
          assert(this->isa_instptr(), "must be an instance ptr.");
          if (klass() == ciEnv::current()->Class_klass() &&
!             (this->offset() == java_lang_Class::klass_offset() ||
!              this->offset() == java_lang_Class::array_klass_offset())) {
            // Special hidden fields from the Class.
            assert(this->isa_instptr(), "must be an instance ptr.");
            _is_ptr_to_narrowoop = false;
          } else if (klass() == ciEnv::current()->Class_klass() &&
!                    this->offset() >= InstanceMirrorKlass::offset_of_static_fields()) {
            // Static fields
            ciField* field = NULL;
            if (const_oop() != NULL) {
              ciInstanceKlass* k = const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass();
!             if (k->is_inlinetype() && this->offset() == k->as_inline_klass()->default_value_offset()) {
!               // Special hidden field that contains the oop of the default inline type
!               // basic_elem_type = T_INLINE_TYPE;
!              _is_ptr_to_narrowoop = UseCompressedOops;
!             } else {
!               field = k->get_field_by_offset(this->offset(), true);
!               if (field != NULL) {
!                 BasicType basic_elem_type = field->layout_type();
+                 _is_ptr_to_narrowoop = UseCompressedOops && is_reference_type(basic_elem_type);
+               } else {
+                 // unsafe access
+                 _is_ptr_to_narrowoop = UseCompressedOops;
+               }
+             }
            }
          } else {
            // Instance fields which contains a compressed oop references.
!           ciInstanceKlass* ik = klass()->as_instance_klass();
+           ciField* field = ik->get_field_by_offset(this->offset(), false);
            if (field != NULL) {
              BasicType basic_elem_type = field->layout_type();
              _is_ptr_to_narrowoop = UseCompressedOops && is_reference_type(basic_elem_type);
            } else if (klass()->equals(ciEnv::current()->Object_klass())) {
              // Compile::find_alias_type() cast exactness on all types to verify

*** 3182,17 ***
    }
  #endif
  }
  
  //------------------------------make-------------------------------------------
! const TypeOopPtr *TypeOopPtr::make(PTR ptr, int offset, int instance_id,
!                                      const TypePtr* speculative, int inline_depth) {
    assert(ptr != Constant, "no constant generic pointers");
    ciKlass*  k = Compile::current()->env()->Object_klass();
    bool      xk = false;
    ciObject* o = NULL;
!   return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
  }
  
  
  //------------------------------cast_to_ptr_type-------------------------------
  const TypeOopPtr* TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
--- 3438,17 ---
    }
  #endif
  }
  
  //------------------------------make-------------------------------------------
! const TypeOopPtr *TypeOopPtr::make(PTR ptr, Offset offset, int instance_id,
!                                    const TypePtr* speculative, int inline_depth) {
    assert(ptr != Constant, "no constant generic pointers");
    ciKlass*  k = Compile::current()->env()->Object_klass();
    bool      xk = false;
    ciObject* o = NULL;
!   return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, Offset::bottom, instance_id, speculative, inline_depth))->hashcons();
  }
  
  
  //------------------------------cast_to_ptr_type-------------------------------
  const TypeOopPtr* TypeOopPtr::cast_to_ptr_type(PTR ptr) const {

*** 3213,11 ***
    // There is no such thing as an exact general oop.
    // Return self unchanged.
    return this;
  }
  
- 
  //------------------------------as_klass_type----------------------------------
  // Return the klass type corresponding to this instance or array type.
  // It is the type that is loaded from an object of this type.
  const TypeKlassPtr* TypeOopPtr::as_klass_type(bool try_for_exact) const {
    ShouldNotReachHere();
--- 3469,10 ---

*** 3259,11 ***
      return TypePtr::BOTTOM;     // Oop meet raw is not well defined
  
    case AnyPtr: {
      // Found an AnyPtr type vs self-OopPtr type
      const TypePtr *tp = t->is_ptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      const TypePtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      switch (tp->ptr()) {
      case Null:
--- 3514,11 ---
      return TypePtr::BOTTOM;     // Oop meet raw is not well defined
  
    case AnyPtr: {
      // Found an AnyPtr type vs self-OopPtr type
      const TypePtr *tp = t->is_ptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      const TypePtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      switch (tp->ptr()) {
      case Null:

*** 3301,17 ***
  //------------------------------xdual------------------------------------------
  // Dual of a pure heap pointer.  No relevant klass or oop information.
  const Type *TypeOopPtr::xdual() const {
    assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
    assert(const_oop() == NULL,             "no constants here");
!   return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
  }
  
  //--------------------------make_from_klass_common-----------------------------
  // Computes the element-type given a klass.
  const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
!   if (klass->is_instance_klass()) {
      Compile* C = Compile::current();
      Dependencies* deps = C->dependencies();
      assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity");
      // Element is an instance
      bool klass_is_exact = false;
--- 3556,17 ---
  //------------------------------xdual------------------------------------------
  // Dual of a pure heap pointer.  No relevant klass or oop information.
  const Type *TypeOopPtr::xdual() const {
    assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
    assert(const_oop() == NULL,             "no constants here");
!   return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), Offset::bottom, dual_instance_id(), dual_speculative(), dual_inline_depth());
  }
  
  //--------------------------make_from_klass_common-----------------------------
  // Computes the element-type given a klass.
  const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
!   if (klass->is_instance_klass() || klass->is_inlinetype()) {
      Compile* C = Compile::current();
      Dependencies* deps = C->dependencies();
      assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity");
      // Element is an instance
      bool klass_is_exact = false;

*** 3333,28 ***
          // Add a dependence; if concrete subclass added we need to recompile
          deps->assert_leaf_type(ik);
          klass_is_exact = true;
        }
      }
!     return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, 0);
    } else if (klass->is_obj_array_klass()) {
!     // Element is an object array. Recursively call ourself.
!     const TypeOopPtr *etype = TypeOopPtr::make_from_klass_common(klass->as_obj_array_klass()->element_klass(), false, try_for_exact);
!     bool xk = etype->klass_is_exact();
!     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
      // We used to pass NotNull in here, asserting that the sub-arrays
      // are all not-null.  This is not true in generally, as code can
      // slam NULLs down in the subarrays.
!     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0);
      return arr;
    } else if (klass->is_type_array_klass()) {
      // Element is an typeArray
      const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
!     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
      // We used to pass NotNull in here, asserting that the array pointer
      // is not-null. That was not true in general.
!     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0);
      return arr;
    } else {
      ShouldNotReachHere();
      return NULL;
    }
--- 3588,48 ---
          // Add a dependence; if concrete subclass added we need to recompile
          deps->assert_leaf_type(ik);
          klass_is_exact = true;
        }
      }
!     return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, Offset(0));
    } else if (klass->is_obj_array_klass()) {
!     // Element is an object or inline type array. Recursively call ourself.
!     const TypeOopPtr* etype = TypeOopPtr::make_from_klass_common(klass->as_array_klass()->element_klass(), /* klass_change= */ false, try_for_exact);
!     bool null_free = klass->as_array_klass()->is_elem_null_free();
!     if (null_free) {
+       etype = etype->join_speculative(TypePtr::NOTNULL)->is_oopptr();
+     }
+     // Determine null-free/flattened properties
+     const TypeOopPtr* exact_etype = etype;
+     if (etype->can_be_inline_type()) {
+       // Use exact type if element can be an inline type
+       exact_etype = TypeOopPtr::make_from_klass_common(klass->as_array_klass()->element_klass(), /* klass_change= */ true, /* try_for_exact= */ true);
+     }
+     bool not_null_free = !exact_etype->can_be_inline_type();
+     bool not_flat = !UseFlatArray || not_null_free || (exact_etype->is_inlinetypeptr() && !exact_etype->inline_klass()->flatten_array());
+ 
+     // Even if MyValue is exact, [LMyValue is not exact due to [QMyValue <: [LMyValue.
+     bool xk = etype->klass_is_exact() && (!etype->is_inlinetypeptr() || null_free);
+     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS, false, not_flat, not_null_free);
      // We used to pass NotNull in here, asserting that the sub-arrays
      // are all not-null.  This is not true in generally, as code can
      // slam NULLs down in the subarrays.
!     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, Offset(0));
      return arr;
    } else if (klass->is_type_array_klass()) {
      // Element is an typeArray
      const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
!     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS,
+                                         /* stable= */ false, /* not_flat= */ true, /* not_null_free= */ true);
      // We used to pass NotNull in here, asserting that the array pointer
      // is not-null. That was not true in general.
!     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, Offset(0));
+     return arr;
+   } else if (klass->is_flat_array_klass()) {
+     ciInlineKlass* vk = klass->as_array_klass()->element_klass()->as_inline_klass();
+     const TypeAry* arr0 = TypeAry::make(TypeInlineType::make(vk), TypeInt::POS);
+     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, Offset(0));
      return arr;
    } else {
      ShouldNotReachHere();
      return NULL;
    }

*** 3366,54 ***
    assert(!o->is_null_object(), "null object not yet handled here.");
  
    const bool make_constant = require_constant || o->should_be_constant();
  
    ciKlass* klass = o->klass();
!   if (klass->is_instance_klass()) {
!     // Element is an instance
      if (make_constant) {
        return TypeInstPtr::make(o);
      } else {
!       return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
      }
    } else if (klass->is_obj_array_klass()) {
      // Element is an object array. Recursively call ourself.
!     const TypeOopPtr *etype =
!       TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass());
!     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
      // We used to pass NotNull in here, asserting that the sub-arrays
      // are all not-null.  This is not true in generally, as code can
      // slam NULLs down in the subarrays.
      if (make_constant) {
!       return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
      } else {
!       return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
      }
    } else if (klass->is_type_array_klass()) {
      // Element is an typeArray
!     const Type* etype =
!       (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
!     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
      // We used to pass NotNull in here, asserting that the array pointer
      // is not-null. That was not true in general.
      if (make_constant) {
!       return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
      } else {
!       return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
      }
    }
  
    fatal("unhandled object type");
    return NULL;
  }
  
  //------------------------------get_con----------------------------------------
  intptr_t TypeOopPtr::get_con() const {
    assert( _ptr == Null || _ptr == Constant, "" );
!   assert( _offset >= 0, "" );
  
!   if (_offset != 0) {
      // After being ported to the compiler interface, the compiler no longer
      // directly manipulates the addresses of oops.  Rather, it only has a pointer
      // to a handle at compile time.  This handle is embedded in the generated
      // code and dereferenced at the time the nmethod is made.  Until that time,
      // it is not reasonable to do arithmetic with the addresses of oops (we don't
--- 3641,70 ---
    assert(!o->is_null_object(), "null object not yet handled here.");
  
    const bool make_constant = require_constant || o->should_be_constant();
  
    ciKlass* klass = o->klass();
!   if (klass->is_instance_klass() || klass->is_inlinetype()) {
!     // Element is an instance or inline type
      if (make_constant) {
        return TypeInstPtr::make(o);
      } else {
!       return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, Offset(0));
      }
    } else if (klass->is_obj_array_klass()) {
      // Element is an object array. Recursively call ourself.
!     const TypeOopPtr* etype = TypeOopPtr::make_from_klass_raw(klass->as_array_klass()->element_klass());
!     bool null_free = false;
!     if (klass->as_array_klass()->is_elem_null_free()) {
+       null_free = true;
+       etype = etype->join_speculative(TypePtr::NOTNULL)->is_oopptr();
+     }
+     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()),
+                                         /* stable= */ false, /* not_flat= */ true, /* not_null_free= */ !null_free);
      // We used to pass NotNull in here, asserting that the sub-arrays
      // are all not-null.  This is not true in generally, as code can
      // slam NULLs down in the subarrays.
      if (make_constant) {
!       return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, Offset(0));
      } else {
!       return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, Offset(0));
      }
    } else if (klass->is_type_array_klass()) {
      // Element is an typeArray
!     const Type* etype = (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
!     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()),
!                                         /* stable= */ false, /* not_flat= */ true, /* not_null_free= */ true);
      // We used to pass NotNull in here, asserting that the array pointer
      // is not-null. That was not true in general.
      if (make_constant) {
!       return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, Offset(0));
      } else {
!       return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, Offset(0));
+     }
+   } else if (klass->is_flat_array_klass()) {
+     ciInlineKlass* vk = klass->as_array_klass()->element_klass()->as_inline_klass();
+     const TypeAry* arr0 = TypeAry::make(TypeInlineType::make(vk), TypeInt::make(o->as_array()->length()));
+     // We used to pass NotNull in here, asserting that the sub-arrays
+     // are all not-null.  This is not true in generally, as code can
+     // slam NULLs down in the subarrays.
+     if (make_constant) {
+       return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, Offset(0));
+     } else {
+       return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, Offset(0));
      }
    }
  
    fatal("unhandled object type");
    return NULL;
  }
  
  //------------------------------get_con----------------------------------------
  intptr_t TypeOopPtr::get_con() const {
    assert( _ptr == Null || _ptr == Constant, "" );
!   assert(offset() >= 0, "");
  
!   if (offset() != 0) {
      // After being ported to the compiler interface, the compiler no longer
      // directly manipulates the addresses of oops.  Rather, it only has a pointer
      // to a handle at compile time.  This handle is embedded in the generated
      // code and dereferenced at the time the nmethod is made.  Until that time,
      // it is not reasonable to do arithmetic with the addresses of oops (we don't

*** 3502,16 ***
  #ifndef PRODUCT
  void TypeOopPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
    st->print("oopptr:%s", ptr_msg[_ptr]);
    if( _klass_is_exact ) st->print(":exact");
    if( const_oop() ) st->print(INTPTR_FORMAT, p2i(const_oop()));
!   switch( _offset ) {
-   case OffsetTop: st->print("+top"); break;
-   case OffsetBot: st->print("+any"); break;
-   case         0: break;
-   default:        st->print("+%d",_offset); break;
-   }
    if (_instance_id == InstanceTop)
      st->print(",iid=top");
    else if (_instance_id != InstanceBot)
      st->print(",iid=%d",_instance_id);
  
--- 3793,11 ---
  #ifndef PRODUCT
  void TypeOopPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
    st->print("oopptr:%s", ptr_msg[_ptr]);
    if( _klass_is_exact ) st->print(":exact");
    if( const_oop() ) st->print(INTPTR_FORMAT, p2i(const_oop()));
!   _offset.dump2(st);
    if (_instance_id == InstanceTop)
      st->print(",iid=top");
    else if (_instance_id != InstanceBot)
      st->print(",iid=%d",_instance_id);
  

*** 3524,11 ***
  // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  // constants
  bool TypeOopPtr::singleton(void) const {
    // detune optimizer to not generate constant oop + constant offset as a constant!
    // TopPTR, Null, AnyNull, Constant are all singletons
!   return (_offset == 0) && !below_centerline(_ptr);
  }
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const {
    return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth);
--- 3810,11 ---
  // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  // constants
  bool TypeOopPtr::singleton(void) const {
    // detune optimizer to not generate constant oop + constant offset as a constant!
    // TopPTR, Null, AnyNull, Constant are all singletons
!   return (offset() == 0) && !below_centerline(_ptr);
  }
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const {
    return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth);

*** 3616,25 ***
  const TypeInstPtr *TypeInstPtr::MIRROR;
  const TypeInstPtr *TypeInstPtr::MARK;
  const TypeInstPtr *TypeInstPtr::KLASS;
  
  //------------------------------TypeInstPtr-------------------------------------
! TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off,
!                          int instance_id, const TypePtr* speculative, int inline_depth)
!   : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth),
!     _name(k->name()) {
!    assert(k != NULL &&
!           (k->is_loaded() || o == NULL),
!           "cannot have constants with non-loaded klass");
  };
  
  //------------------------------make-------------------------------------------
  const TypeInstPtr *TypeInstPtr::make(PTR ptr,
                                       ciKlass* k,
                                       bool xk,
                                       ciObject* o,
!                                      int offset,
                                       int instance_id,
                                       const TypePtr* speculative,
                                       int inline_depth) {
    assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
    // Either const_oop() is NULL or else ptr is Constant
--- 3902,29 ---
  const TypeInstPtr *TypeInstPtr::MIRROR;
  const TypeInstPtr *TypeInstPtr::MARK;
  const TypeInstPtr *TypeInstPtr::KLASS;
  
  //------------------------------TypeInstPtr-------------------------------------
! TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset off,
!                          bool flatten_array, int instance_id, const TypePtr* speculative,
!                          int inline_depth)
!   : TypeOopPtr(InstPtr, ptr, k, xk, o, off, Offset::bottom, instance_id, speculative, inline_depth),
!     _name(k->name()), _flatten_array(flatten_array) {
!   assert(k != NULL &&
!          (k->is_loaded() || o == NULL),
+          "cannot have constants with non-loaded klass");
+   assert(!klass()->flatten_array() || flatten_array, "Should be flat in array");
+   assert(!flatten_array || can_be_inline_type(), "Only inline types can be flat in array");
  };
  
  //------------------------------make-------------------------------------------
  const TypeInstPtr *TypeInstPtr::make(PTR ptr,
                                       ciKlass* k,
                                       bool xk,
                                       ciObject* o,
!                                      Offset offset,
+                                      bool flatten_array,
                                       int instance_id,
                                       const TypePtr* speculative,
                                       int inline_depth) {
    assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
    // Either const_oop() is NULL or else ptr is Constant

*** 3651,13 ***
      ciInstanceKlass* ik = k->as_instance_klass();
      if (!xk && ik->is_final())     xk = true;   // no inexact final klass
      if (xk && ik->is_interface())  xk = false;  // no exact interface
    }
  
    // Now hash this baby
    TypeInstPtr *result =
!     (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative, inline_depth))->hashcons();
  
    return result;
  }
  
  /**
--- 3941,16 ---
      ciInstanceKlass* ik = k->as_instance_klass();
      if (!xk && ik->is_final())     xk = true;   // no inexact final klass
      if (xk && ik->is_interface())  xk = false;  // no exact interface
    }
  
+   // Check if this type is known to be flat in arrays
+   flatten_array = flatten_array || k->flatten_array();
+ 
    // Now hash this baby
    TypeInstPtr *result =
!     (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o, offset, flatten_array, instance_id, speculative, inline_depth))->hashcons();
  
    return result;
  }
  
  /**

*** 3686,35 ***
  //------------------------------cast_to_ptr_type-------------------------------
  const TypeInstPtr *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
    if( ptr == _ptr ) return this;
    // Reconstruct _sig info here since not a problem with later lazy
    // construction, _sig will show up on demand.
!   return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth);
  }
  
  
  //-----------------------------cast_to_exactness-------------------------------
  const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
    if( klass_is_exact == _klass_is_exact ) return this;
    if (!_klass->is_loaded())  return this;
    ciInstanceKlass* ik = _klass->as_instance_klass();
    if( (ik->is_final() || _const_oop) )  return this;  // cannot clear xk
    if( ik->is_interface() )              return this;  // cannot set xk
!   return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth);
  }
  
  //-----------------------------cast_to_instance_id----------------------------
  const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
    if( instance_id == _instance_id ) return this;
!   return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth);
  }
  
  //------------------------------xmeet_unloaded---------------------------------
  // Compute the MEET of two InstPtrs when at least one is unloaded.
  // Assume classes are different since called after check for same name/class-loader
  const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
!     int off = meet_offset(tinst->offset());
      PTR ptr = meet_ptr(tinst->ptr());
      int instance_id = meet_instance_id(tinst->instance_id());
      const TypePtr* speculative = xmeet_speculative(tinst);
      int depth = meet_inline_depth(tinst->inline_depth());
  
--- 3979,35 ---
  //------------------------------cast_to_ptr_type-------------------------------
  const TypeInstPtr *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
    if( ptr == _ptr ) return this;
    // Reconstruct _sig info here since not a problem with later lazy
    // construction, _sig will show up on demand.
!   return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _flatten_array, _instance_id, _speculative, _inline_depth);
  }
  
  
  //-----------------------------cast_to_exactness-------------------------------
  const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
    if( klass_is_exact == _klass_is_exact ) return this;
    if (!_klass->is_loaded())  return this;
    ciInstanceKlass* ik = _klass->as_instance_klass();
    if( (ik->is_final() || _const_oop) )  return this;  // cannot clear xk
    if( ik->is_interface() )              return this;  // cannot set xk
!   return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _flatten_array, _instance_id, _speculative, _inline_depth);
  }
  
  //-----------------------------cast_to_instance_id----------------------------
  const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
    if( instance_id == _instance_id ) return this;
!   return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, _flatten_array, instance_id, _speculative, _inline_depth);
  }
  
  //------------------------------xmeet_unloaded---------------------------------
  // Compute the MEET of two InstPtrs when at least one is unloaded.
  // Assume classes are different since called after check for same name/class-loader
  const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
!     Offset off = meet_offset(tinst->offset());
      PTR ptr = meet_ptr(tinst->ptr());
      int instance_id = meet_instance_id(tinst->instance_id());
      const TypePtr* speculative = xmeet_speculative(tinst);
      int depth = meet_inline_depth(tinst->inline_depth());
  

*** 3735,11 ***
        //  BOTTOM  | ........................Object-BOTTOM ..................|
        //
        assert(loaded->ptr() != TypePtr::Null, "insanity check");
        //
        if(      loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
!       else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative, depth); }
        else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
        else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
          if (unloaded->ptr() == TypePtr::BotPTR  ) { return TypeInstPtr::BOTTOM;  }
          else                                      { return TypeInstPtr::NOTNULL; }
        }
--- 4028,11 ---
        //  BOTTOM  | ........................Object-BOTTOM ..................|
        //
        assert(loaded->ptr() != TypePtr::Null, "insanity check");
        //
        if(      loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
!       else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, false, instance_id, speculative, depth); }
        else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
        else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
          if (unloaded->ptr() == TypePtr::BotPTR  ) { return TypeInstPtr::BOTTOM;  }
          else                                      { return TypeInstPtr::NOTNULL; }
        }

*** 3796,20 ***
    }
  
    case OopPtr: {                // Meeting to OopPtrs
      // Found a OopPtr type vs self-InstPtr type
      const TypeOopPtr *tp = t->is_oopptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      switch (tp->ptr()) {
      case TopPTR:
      case AnyNull: {
        int instance_id = meet_instance_id(InstanceTop);
        const TypePtr* speculative = xmeet_speculative(tp);
        int depth = meet_inline_depth(tp->inline_depth());
        return make(ptr, klass(), klass_is_exact(),
!                   (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, depth);
      }
      case NotNull:
      case BotPTR: {
        int instance_id = meet_instance_id(tp->instance_id());
        const TypePtr* speculative = xmeet_speculative(tp);
--- 4089,20 ---
    }
  
    case OopPtr: {                // Meeting to OopPtrs
      // Found a OopPtr type vs self-InstPtr type
      const TypeOopPtr *tp = t->is_oopptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      switch (tp->ptr()) {
      case TopPTR:
      case AnyNull: {
        int instance_id = meet_instance_id(InstanceTop);
        const TypePtr* speculative = xmeet_speculative(tp);
        int depth = meet_inline_depth(tp->inline_depth());
        return make(ptr, klass(), klass_is_exact(),
!                   (ptr == Constant ? const_oop() : NULL), offset, flatten_array(), instance_id, speculative, depth);
      }
      case NotNull:
      case BotPTR: {
        int instance_id = meet_instance_id(tp->instance_id());
        const TypePtr* speculative = xmeet_speculative(tp);

*** 3821,11 ***
    }
  
    case AnyPtr: {                // Meeting to AnyPtrs
      // Found an AnyPtr type vs self-InstPtr type
      const TypePtr *tp = t->is_ptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      int instance_id = meet_instance_id(InstanceTop);
      const TypePtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      switch (tp->ptr()) {
--- 4114,11 ---
    }
  
    case AnyPtr: {                // Meeting to AnyPtrs
      // Found an AnyPtr type vs self-InstPtr type
      const TypePtr *tp = t->is_ptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      int instance_id = meet_instance_id(InstanceTop);
      const TypePtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      switch (tp->ptr()) {

*** 3833,11 ***
        if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth);
        // else fall through to AnyNull
      case TopPTR:
      case AnyNull: {
        return make(ptr, klass(), klass_is_exact(),
!                   (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, depth);
      }
      case NotNull:
      case BotPTR:
        return TypePtr::make(AnyPtr, ptr, offset, speculative,depth);
      default: typerr(t);
--- 4126,11 ---
        if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth);
        // else fall through to AnyNull
      case TopPTR:
      case AnyNull: {
        return make(ptr, klass(), klass_is_exact(),
!                   (ptr == Constant ? const_oop() : NULL), offset, flatten_array(), instance_id, speculative, depth);
      }
      case NotNull:
      case BotPTR:
        return TypePtr::make(AnyPtr, ptr, offset, speculative,depth);
      default: typerr(t);

*** 3861,24 ***
    */
  
    case InstPtr: {                // Meeting 2 Oops?
      // Found an InstPtr sub-type vs self-InstPtr type
      const TypeInstPtr *tinst = t->is_instptr();
!     int off = meet_offset(tinst->offset());
      PTR ptr = meet_ptr(tinst->ptr());
      int instance_id = meet_instance_id(tinst->instance_id());
      const TypePtr* speculative = xmeet_speculative(tinst);
      int depth = meet_inline_depth(tinst->inline_depth());
      ciKlass* tinst_klass = tinst->klass();
      ciKlass* this_klass  = klass();
      bool tinst_xk = tinst->klass_is_exact();
!     bool this_xk  = klass_is_exact();
  
      ciKlass* res_klass = NULL;
      bool res_xk = false;
      const Type* res;
!     MeetResult kind = meet_instptr(ptr, this_klass, tinst_klass, this_xk, tinst_xk, this->_ptr, tinst->_ptr, res_klass, res_xk);
      if (kind == UNLOADED) {
        // One of these classes has not been loaded
        const TypeInstPtr* unloaded_meet = xmeet_unloaded(tinst);
  #ifndef PRODUCT
        if (PrintOpto && Verbose) {
--- 4154,29 ---
    */
  
    case InstPtr: {                // Meeting 2 Oops?
      // Found an InstPtr sub-type vs self-InstPtr type
      const TypeInstPtr *tinst = t->is_instptr();
!     Offset off = meet_offset(tinst->offset());
      PTR ptr = meet_ptr(tinst->ptr());
      int instance_id = meet_instance_id(tinst->instance_id());
      const TypePtr* speculative = xmeet_speculative(tinst);
      int depth = meet_inline_depth(tinst->inline_depth());
      ciKlass* tinst_klass = tinst->klass();
      ciKlass* this_klass  = klass();
      bool tinst_xk = tinst->klass_is_exact();
!     bool this_xk  = this->klass_is_exact();
+     bool tinst_flatten_array = tinst->flatten_array();
+     bool this_flatten_array  = this->flatten_array();
  
      ciKlass* res_klass = NULL;
      bool res_xk = false;
+     bool res_flatten_array = false;
      const Type* res;
!     MeetResult kind = meet_instptr(ptr, this_klass, tinst_klass, this_xk, tinst_xk, this->_ptr, tinst->_ptr,
+                                    this_flatten_array, tinst_flatten_array,
+                                    res_klass, res_xk, res_flatten_array);
      if (kind == UNLOADED) {
        // One of these classes has not been loaded
        const TypeInstPtr* unloaded_meet = xmeet_unloaded(tinst);
  #ifndef PRODUCT
        if (PrintOpto && Verbose) {

*** 3914,32 ***
            assert(!this_klass->is_interface(), "");
            o = this_oop;
          } else
            ptr = NotNull;
        }
!       res = make(ptr, res_klass, res_xk, o, off, instance_id, speculative, depth);
      }
  
      return res;
  
    } // End of case InstPtr
  
    } // End of switch
    return this;                  // Return the double constant
  }
  
  TypePtr::MeetResult TypePtr::meet_instptr(PTR &ptr, ciKlass* this_klass, ciKlass* tinst_klass, bool this_xk, bool tinst_xk,
!                                           PTR this_ptr,
!                                           PTR tinst_ptr, ciKlass*&res_klass, bool &res_xk) {
  
    // Check for easy case; klasses are equal (and perhaps not loaded!)
    // If we have constants, then we created oops so classes are loaded
    // and we can handle the constants further down.  This case handles
    // both-not-loaded or both-loaded classes
!   if (ptr != Constant && this_klass->equals(tinst_klass) && this_xk == tinst_xk) {
      res_klass = this_klass;
      res_xk = this_xk;
      return QUICK;
    }
  
    // Classes require inspection in the Java klass hierarchy.  Must be loaded.
    if (!tinst_klass->is_loaded() || !this_klass->is_loaded()) {
--- 4212,57 ---
            assert(!this_klass->is_interface(), "");
            o = this_oop;
          } else
            ptr = NotNull;
        }
!       res = make(ptr, res_klass, res_xk, o, off, res_flatten_array, instance_id, speculative, depth);
      }
  
      return res;
  
    } // End of case InstPtr
  
+   case InlineType: {
+     const TypeInlineType* tv = t->is_inlinetype();
+     if (above_centerline(ptr())) {
+       if (tv->inline_klass()->is_subtype_of(_klass)) {
+         return t;
+       } else {
+         return TypeInstPtr::NOTNULL;
+       }
+     } else {
+       PTR ptr = this->_ptr;
+       if (ptr == Constant) {
+         ptr = NotNull;
+       }
+       if (tv->inline_klass()->is_subtype_of(_klass)) {
+         return make(ptr, _klass, false, NULL, Offset(0), _flatten_array, InstanceBot, _speculative);
+       } else {
+         return make(ptr, ciEnv::current()->Object_klass());
+       }
+     }
+   }
+ 
    } // End of switch
    return this;                  // Return the double constant
  }
  
  TypePtr::MeetResult TypePtr::meet_instptr(PTR &ptr, ciKlass* this_klass, ciKlass* tinst_klass, bool this_xk, bool tinst_xk,
!                                           PTR this_ptr, PTR tinst_ptr, bool this_flatten_array, bool tinst_flatten_array,
!                                           ciKlass*&res_klass, bool &res_xk, bool& res_flatten_array) {
+ 
+   bool this_flatten_array_orig = this_flatten_array;
+   bool tinst_flatten_array_orig = tinst_flatten_array;
  
    // Check for easy case; klasses are equal (and perhaps not loaded!)
    // If we have constants, then we created oops so classes are loaded
    // and we can handle the constants further down.  This case handles
    // both-not-loaded or both-loaded classes
!   if (ptr != Constant && this_klass->equals(tinst_klass) && this_xk == tinst_xk && this_flatten_array == tinst_flatten_array) {
      res_klass = this_klass;
      res_xk = this_xk;
+     res_flatten_array = this_flatten_array;
      return QUICK;
    }
  
    // Classes require inspection in the Java klass hierarchy.  Must be loaded.
    if (!tinst_klass->is_loaded() || !this_klass->is_loaded()) {

*** 3953,10 ***
--- 4276,13 ---
      tinst_klass = this_klass;
      this_klass = tmp;
      bool tmp2 = tinst_xk;
      tinst_xk = this_xk;
      this_xk = tmp2;
+     tmp2 = tinst_flatten_array;
+     tinst_flatten_array = this_flatten_array;
+     this_flatten_array = tmp2;
    }
    if (tinst_klass->is_interface() &&
        !(this_klass->is_interface() ||
          // Treat java/lang/Object as an honorary interface,
          // because we need a bottom for the interface hierarchy.

*** 3970,17 ***
--- 4296,19 ---
        // below the centerline.  If we are on the centerline
        // (e.g., Constant vs. AnyNull interface), use the constant.
        res_klass  = below_centerline(ptr) ? tinst_klass : this_klass;
        // If we are keeping this_klass, keep its exactness too.
        res_xk = below_centerline(ptr) ? tinst_xk    : this_xk;
+       res_flatten_array = below_centerline(ptr) ? tinst_flatten_array    : this_flatten_array;
        return SUBTYPE;
      } else {                  // Does not implement, fall to Object
        // Oop does not implement interface, so mixing falls to Object
        // just like the verifier does (if both are above the
        // centerline fall to interface)
        res_klass = above_centerline(ptr) ? tinst_klass : ciEnv::current()->Object_klass();
        res_xk = above_centerline(ptr) ? tinst_xk : false;
+       res_flatten_array = above_centerline(ptr) ? tinst_flatten_array : false;
        // Watch out for Constant vs. AnyNull interface.
        if (ptr == Constant)  ptr = NotNull;   // forget it was a constant
        return NOT_SUBTYPE;
      }
    }

*** 4012,43 ***
    // centerline and or-ed above it.  (N.B. Constants are always exact.)
  
    // Check for subtyping:
    ciKlass *subtype = NULL;
    bool subtype_exact = false;
    if (tinst_klass->equals(this_klass)) {
      subtype = this_klass;
      subtype_exact = below_centerline(ptr) ? (this_xk && tinst_xk) : (this_xk || tinst_xk);
!   } else if (!tinst_xk && this_klass->is_subtype_of(tinst_klass)) {
      subtype = this_klass;     // Pick subtyping class
      subtype_exact = this_xk;
!   } else if (!this_xk && tinst_klass->is_subtype_of(this_klass)) {
      subtype = tinst_klass;    // Pick subtyping class
      subtype_exact = tinst_xk;
    }
  
    if (subtype) {
      if (above_centerline(ptr)) { // both are up?
        this_klass = tinst_klass = subtype;
        this_xk = tinst_xk = subtype_exact;
      } else if (above_centerline(this_ptr) && !above_centerline(tinst_ptr)) {
        this_klass = tinst_klass; // tinst is down; keep down man
        this_xk = tinst_xk;
      } else if (above_centerline(tinst_ptr) && !above_centerline(this_ptr)) {
        tinst_klass = this_klass; // this is down; keep down man
        tinst_xk = this_xk;
      } else {
        this_xk = subtype_exact;  // either they are equal, or we'll do an LCA
      }
    }
  
    // Check for classes now being equal
    if (tinst_klass->equals(this_klass)) {
      // If the klasses are equal, the constants may still differ.  Fall to
      // NotNull if they do (neither constant is NULL; that is a special case
      // handled elsewhere).
      res_klass = this_klass;
      res_xk = this_xk;
      return SUBTYPE;
    } // Else classes are not equal
  
    // Since klasses are different, we require a LCA in the Java
    // class hierarchy - which means we have to fall to at least NotNull.
--- 4340,52 ---
    // centerline and or-ed above it.  (N.B. Constants are always exact.)
  
    // Check for subtyping:
    ciKlass *subtype = NULL;
    bool subtype_exact = false;
+   bool flat_array = false;
    if (tinst_klass->equals(this_klass)) {
      subtype = this_klass;
      subtype_exact = below_centerline(ptr) ? (this_xk && tinst_xk) : (this_xk || tinst_xk);
!     flat_array = below_centerline(ptr) ? (this_flatten_array && tinst_flatten_array) : (this_flatten_array || tinst_flatten_array);
+   } else if (!tinst_xk && this_klass->is_subtype_of(tinst_klass) && (!tinst_flatten_array || this_flatten_array)) {
      subtype = this_klass;     // Pick subtyping class
      subtype_exact = this_xk;
!     flat_array = this_flatten_array;
+   } else if (!this_xk && tinst_klass->is_subtype_of(this_klass) && (!this_flatten_array || tinst_flatten_array)) {
      subtype = tinst_klass;    // Pick subtyping class
      subtype_exact = tinst_xk;
+     flat_array = tinst_flatten_array;
    }
  
    if (subtype) {
      if (above_centerline(ptr)) { // both are up?
        this_klass = tinst_klass = subtype;
        this_xk = tinst_xk = subtype_exact;
+       this_flatten_array = tinst_flatten_array = flat_array;
      } else if (above_centerline(this_ptr) && !above_centerline(tinst_ptr)) {
        this_klass = tinst_klass; // tinst is down; keep down man
        this_xk = tinst_xk;
+       this_flatten_array = tinst_flatten_array;
      } else if (above_centerline(tinst_ptr) && !above_centerline(this_ptr)) {
        tinst_klass = this_klass; // this is down; keep down man
        tinst_xk = this_xk;
+       tinst_flatten_array = this_flatten_array;
      } else {
        this_xk = subtype_exact;  // either they are equal, or we'll do an LCA
+       this_flatten_array = flat_array;
      }
    }
  
    // Check for classes now being equal
    if (tinst_klass->equals(this_klass)) {
      // If the klasses are equal, the constants may still differ.  Fall to
      // NotNull if they do (neither constant is NULL; that is a special case
      // handled elsewhere).
      res_klass = this_klass;
      res_xk = this_xk;
+     res_flatten_array = this_flatten_array;
      return SUBTYPE;
    } // Else classes are not equal
  
    // Since klasses are different, we require a LCA in the Java
    // class hierarchy - which means we have to fall to at least NotNull.

*** 4059,47 ***
    // Now we find the LCA of Java classes
    ciKlass* k = this_klass->least_common_ancestor(tinst_klass);
  
    res_klass = k;
    res_xk = false;
  
    return LCA;
  }
  
  
  //------------------------java_mirror_type--------------------------------------
! ciType* TypeInstPtr::java_mirror_type() const {
    // must be a singleton type
    if( const_oop() == NULL )  return NULL;
  
    // must be of type java.lang.Class
    if( klass() != ciEnv::current()->Class_klass() )  return NULL;
! 
-   return const_oop()->as_instance()->java_mirror_type();
  }
  
  
  //------------------------------xdual------------------------------------------
  // Dual: do NOT dual on klasses.  This means I do NOT understand the Java
  // inheritance mechanism.
  const Type *TypeInstPtr::xdual() const {
!   return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeInstPtr::eq( const Type *t ) const {
    const TypeInstPtr *p = t->is_instptr();
    return
      klass()->equals(p->klass()) &&
      TypeOopPtr::eq(p);          // Check sub-type stuff
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeInstPtr::hash(void) const {
!   int hash = java_add((jint)klass()->hash(), (jint)TypeOopPtr::hash());
    return hash;
  }
  
  //------------------------------dump2------------------------------------------
  // Dump oop Type
--- 4396,48 ---
    // Now we find the LCA of Java classes
    ciKlass* k = this_klass->least_common_ancestor(tinst_klass);
  
    res_klass = k;
    res_xk = false;
+   res_flatten_array = this_flatten_array_orig && tinst_flatten_array_orig;
  
    return LCA;
  }
  
  
  //------------------------java_mirror_type--------------------------------------
! ciType* TypeInstPtr::java_mirror_type(bool* is_val_mirror) const {
    // must be a singleton type
    if( const_oop() == NULL )  return NULL;
  
    // must be of type java.lang.Class
    if( klass() != ciEnv::current()->Class_klass() )  return NULL;
!   return const_oop()->as_instance()->java_mirror_type(is_val_mirror);
  }
  
  
  //------------------------------xdual------------------------------------------
  // Dual: do NOT dual on klasses.  This means I do NOT understand the Java
  // inheritance mechanism.
  const Type *TypeInstPtr::xdual() const {
!   return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), flatten_array(), dual_instance_id(), dual_speculative(), dual_inline_depth());
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeInstPtr::eq( const Type *t ) const {
    const TypeInstPtr *p = t->is_instptr();
    return
      klass()->equals(p->klass()) &&
+     flatten_array() == p->flatten_array() &&
      TypeOopPtr::eq(p);          // Check sub-type stuff
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeInstPtr::hash(void) const {
!   int hash = java_add(java_add((jint)klass()->hash(), (jint)TypeOopPtr::hash()), (jint)flatten_array());
    return hash;
  }
  
  //------------------------------dump2------------------------------------------
  // Dump oop Type

*** 4135,17 ***
      break;
    default:
      break;
    }
  
!   if( _offset ) {               // Dump offset, if any
-     if( _offset == OffsetBot )      st->print("+any");
-     else if( _offset == OffsetTop ) st->print("+unknown");
-     else st->print("+%d", _offset);
-   }
  
    st->print(" *");
    if (_instance_id == InstanceTop)
      st->print(",iid=top");
    else if (_instance_id != InstanceBot)
      st->print(",iid=%d",_instance_id);
  
--- 4473,18 ---
      break;
    default:
      break;
    }
  
!   _offset.dump2(st);
  
    st->print(" *");
+ 
+   if (flatten_array() && !klass()->is_inlinetype()) {
+     st->print(" (flatten array)");
+   }
+ 
    if (_instance_id == InstanceTop)
      st->print(",iid=top");
    else if (_instance_id != InstanceBot)
      st->print(",iid=%d",_instance_id);
  

*** 4154,33 ***
  }
  #endif
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const {
!   return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset),
                _instance_id, add_offset_speculative(offset), _inline_depth);
  }
  
  const Type *TypeInstPtr::remove_speculative() const {
    if (_speculative == NULL) {
      return this;
    }
    assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
!   return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset,
                _instance_id, NULL, _inline_depth);
  }
  
  const TypePtr *TypeInstPtr::with_inline_depth(int depth) const {
    if (!UseInlineDepthForSpeculativeTypes) {
      return this;
    }
!   return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth);
  }
  
  const TypePtr *TypeInstPtr::with_instance_id(int instance_id) const {
    assert(is_known_instance(), "should be known");
!   return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, instance_id, _speculative, _inline_depth);
  }
  
  const TypeKlassPtr* TypeInstPtr::as_klass_type(bool try_for_exact) const {
    bool xk = klass_is_exact();
    ciInstanceKlass* ik = klass()->as_instance_klass();
--- 4493,37 ---
  }
  #endif
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const {
!   return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), flatten_array(),
                _instance_id, add_offset_speculative(offset), _inline_depth);
  }
  
  const Type *TypeInstPtr::remove_speculative() const {
    if (_speculative == NULL) {
      return this;
    }
    assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
!   return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, flatten_array(),
                _instance_id, NULL, _inline_depth);
  }
  
  const TypePtr *TypeInstPtr::with_inline_depth(int depth) const {
    if (!UseInlineDepthForSpeculativeTypes) {
      return this;
    }
!   return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, flatten_array(), _instance_id, _speculative, depth);
  }
  
  const TypePtr *TypeInstPtr::with_instance_id(int instance_id) const {
    assert(is_known_instance(), "should be known");
!   return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, flatten_array(), instance_id, _speculative, _inline_depth);
+ }
+ 
+ const TypeInstPtr *TypeInstPtr::cast_to_flatten_array() const {
+   return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, true, _instance_id, _speculative, _inline_depth);
  }
  
  const TypeKlassPtr* TypeInstPtr::as_klass_type(bool try_for_exact) const {
    bool xk = klass_is_exact();
    ciInstanceKlass* ik = klass()->as_instance_klass();

*** 4188,11 ***
      Compile* C = Compile::current();
      Dependencies* deps = C->dependencies();
      deps->assert_leaf_type(ik);
      xk = true;
    }
!   return TypeInstKlassPtr::make(xk ? TypePtr::Constant : TypePtr::NotNull, klass(), 0);
  }
  
  //=============================================================================
  // Convenience common pre-built types.
  const TypeAryPtr *TypeAryPtr::RANGE;
--- 4531,11 ---
      Compile* C = Compile::current();
      Dependencies* deps = C->dependencies();
      deps->assert_leaf_type(ik);
      xk = true;
    }
!   return TypeInstKlassPtr::make(xk ? TypePtr::Constant : TypePtr::NotNull, klass(), Offset(0), flatten_array());
  }
  
  //=============================================================================
  // Convenience common pre-built types.
  const TypeAryPtr *TypeAryPtr::RANGE;

*** 4203,51 ***
  const TypeAryPtr *TypeAryPtr::CHARS;
  const TypeAryPtr *TypeAryPtr::INTS;
  const TypeAryPtr *TypeAryPtr::LONGS;
  const TypeAryPtr *TypeAryPtr::FLOATS;
  const TypeAryPtr *TypeAryPtr::DOUBLES;
  
  //------------------------------make-------------------------------------------
! const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset,
                                     int instance_id, const TypePtr* speculative, int inline_depth) {
    assert(!(k == NULL && ary->_elem->isa_int()),
           "integral arrays must be pre-equipped with a class");
    if (!xk)  xk = ary->ary_must_be_exact();
    assert(instance_id <= 0 || xk, "instances are always exactly typed");
!   return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative, inline_depth))->hashcons();
  }
  
  //------------------------------make-------------------------------------------
! const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,
                                     int instance_id, const TypePtr* speculative, int inline_depth,
                                     bool is_autobox_cache) {
    assert(!(k == NULL && ary->_elem->isa_int()),
           "integral arrays must be pre-equipped with a class");
    assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
    if (!xk)  xk = (o != NULL) || ary->ary_must_be_exact();
    assert(instance_id <= 0 || xk, "instances are always exactly typed");
!   return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons();
  }
  
  //------------------------------cast_to_ptr_type-------------------------------
  const TypeAryPtr* TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
    if( ptr == _ptr ) return this;
!   return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
  }
  
  
  //-----------------------------cast_to_exactness-------------------------------
  const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
    if( klass_is_exact == _klass_is_exact ) return this;
    if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
!   return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
  }
  
  //-----------------------------cast_to_instance_id----------------------------
  const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
    if( instance_id == _instance_id ) return this;
!   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
  }
  
  
  //-----------------------------max_array_length-------------------------------
  // A wrapper around arrayOopDesc::max_array_length(etype) with some input normalization.
--- 4546,58 ---
  const TypeAryPtr *TypeAryPtr::CHARS;
  const TypeAryPtr *TypeAryPtr::INTS;
  const TypeAryPtr *TypeAryPtr::LONGS;
  const TypeAryPtr *TypeAryPtr::FLOATS;
  const TypeAryPtr *TypeAryPtr::DOUBLES;
+ const TypeAryPtr *TypeAryPtr::INLINES;
  
  //------------------------------make-------------------------------------------
! const TypeAryPtr* TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset, Offset field_offset,
                                     int instance_id, const TypePtr* speculative, int inline_depth) {
    assert(!(k == NULL && ary->_elem->isa_int()),
           "integral arrays must be pre-equipped with a class");
    if (!xk)  xk = ary->ary_must_be_exact();
    assert(instance_id <= 0 || xk, "instances are always exactly typed");
!   return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, field_offset, instance_id, false, speculative, inline_depth))->hashcons();
  }
  
  //------------------------------make-------------------------------------------
! const TypeAryPtr* TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset, Offset field_offset,
                                     int instance_id, const TypePtr* speculative, int inline_depth,
                                     bool is_autobox_cache) {
    assert(!(k == NULL && ary->_elem->isa_int()),
           "integral arrays must be pre-equipped with a class");
    assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
    if (!xk)  xk = (o != NULL) || ary->ary_must_be_exact();
    assert(instance_id <= 0 || xk, "instances are always exactly typed");
!   return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, field_offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons();
  }
  
  //------------------------------cast_to_ptr_type-------------------------------
  const TypeAryPtr* TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
    if( ptr == _ptr ) return this;
!   return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
  }
  
  
  //-----------------------------cast_to_exactness-------------------------------
  const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
    if( klass_is_exact == _klass_is_exact ) return this;
    if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
! 
+   const TypeAry* new_ary = _ary;
+   if (klass() != NULL && klass()->is_obj_array_klass() && klass_is_exact) {
+     // An object array can't be flat or null-free if the klass is exact
+     new_ary = TypeAry::make(elem(), size(), is_stable(), /* not_flat= */ true, /* not_null_free= */ true);
+   }
+   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact, _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
  }
  
  //-----------------------------cast_to_instance_id----------------------------
  const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
    if( instance_id == _instance_id ) return this;
!   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, _field_offset, instance_id, _speculative, _inline_depth, _is_autobox_cache);
  }
  
  
  //-----------------------------max_array_length-------------------------------
  // A wrapper around arrayOopDesc::max_array_length(etype) with some input normalization.

*** 4299,12 ***
  //-------------------------------cast_to_size----------------------------------
  const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
    assert(new_size != NULL, "");
    new_size = narrow_size_type(new_size);
    if (new_size == size())  return this;
!   const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable());
!   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
  }
  
  //------------------------------cast_to_stable---------------------------------
  const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const {
    if (stable_dimension <= 0 || (stable_dimension == 1 && stable == this->is_stable()))
--- 4649,46 ---
  //-------------------------------cast_to_size----------------------------------
  const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
    assert(new_size != NULL, "");
    new_size = narrow_size_type(new_size);
    if (new_size == size())  return this;
!   const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable(), is_not_flat(), is_not_null_free());
!   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
+ }
+ 
+ //-------------------------------cast_to_not_flat------------------------------
+ const TypeAryPtr* TypeAryPtr::cast_to_not_flat(bool not_flat) const {
+   if (not_flat == is_not_flat()) {
+     return this;
+   }
+   const TypeAry* new_ary = TypeAry::make(elem(), size(), is_stable(), not_flat, is_not_null_free());
+   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
+ }
+ 
+ //-------------------------------cast_to_not_null_free-------------------------
+ const TypeAryPtr* TypeAryPtr::cast_to_not_null_free(bool not_null_free) const {
+   if (not_null_free == is_not_null_free()) {
+     return this;
+   }
+   // Not null free implies not flat
+   const TypeAry* new_ary = TypeAry::make(elem(), size(), is_stable(), not_null_free ? true : is_not_flat(), not_null_free);
+   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
+ }
+ 
+ //---------------------------------update_properties---------------------------
+ const TypeAryPtr* TypeAryPtr::update_properties(const TypeAryPtr* from) const {
+   if ((from->is_flat()          && is_not_flat()) ||
+       (from->is_not_flat()      && is_flat()) ||
+       (from->is_null_free()     && is_not_null_free()) ||
+       (from->is_not_null_free() && is_null_free())) {
+     return NULL; // Inconsistent properties
+   } else if (from->is_not_null_free()) {
+     return cast_to_not_null_free(); // Implies not flat
+   } else if (from->is_not_flat()) {
+     return cast_to_not_flat();
+   }
+   return this;
  }
  
  //------------------------------cast_to_stable---------------------------------
  const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const {
    if (stable_dimension <= 0 || (stable_dimension == 1 && stable == this->is_stable()))

*** 4316,13 ***
    if (stable_dimension > 1 && elem_ptr != NULL && elem_ptr->isa_aryptr()) {
      // If this is widened from a narrow oop, TypeAry::make will re-narrow it.
      elem = elem_ptr = elem_ptr->is_aryptr()->cast_to_stable(stable, stable_dimension - 1);
    }
  
!   const TypeAry* new_ary = TypeAry::make(elem, size(), stable);
  
!   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
  }
  
  //-----------------------------stable_dimension--------------------------------
  int TypeAryPtr::stable_dimension() const {
    if (!is_stable())  return 0;
--- 4700,13 ---
    if (stable_dimension > 1 && elem_ptr != NULL && elem_ptr->isa_aryptr()) {
      // If this is widened from a narrow oop, TypeAry::make will re-narrow it.
      elem = elem_ptr = elem_ptr->is_aryptr()->cast_to_stable(stable, stable_dimension - 1);
    }
  
!   const TypeAry* new_ary = TypeAry::make(elem, size(), stable, is_not_flat(), is_not_null_free());
  
!   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
  }
  
  //-----------------------------stable_dimension--------------------------------
  int TypeAryPtr::stable_dimension() const {
    if (!is_stable())  return 0;

*** 4338,27 ***
    if (is_autobox_cache())  return this;
    const TypeOopPtr* etype = elem()->make_oopptr();
    if (etype == NULL)  return this;
    // The pointers in the autobox arrays are always non-null.
    etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
!   const TypeAry* new_ary = TypeAry::make(etype, size(), is_stable());
!   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth, /*is_autobox_cache=*/true);
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeAryPtr::eq( const Type *t ) const {
    const TypeAryPtr *p = t->is_aryptr();
    return
      _ary == p->_ary &&  // Check array
!     TypeOopPtr::eq(p);  // Check sub-parts
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeAryPtr::hash(void) const {
!   return (intptr_t)_ary + TypeOopPtr::hash();
  }
  
  //------------------------------meet-------------------------------------------
  // Compute the MEET of two types.  It returns a new Type object.
  const Type *TypeAryPtr::xmeet_helper(const Type *t) const {
--- 4722,28 ---
    if (is_autobox_cache())  return this;
    const TypeOopPtr* etype = elem()->make_oopptr();
    if (etype == NULL)  return this;
    // The pointers in the autobox arrays are always non-null.
    etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
!   const TypeAry* new_ary = TypeAry::make(etype, size(), is_stable(), is_not_flat(), is_not_null_free());
!   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, /*is_autobox_cache=*/true);
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeAryPtr::eq( const Type *t ) const {
    const TypeAryPtr *p = t->is_aryptr();
    return
      _ary == p->_ary &&  // Check array
!     TypeOopPtr::eq(p) &&// Check sub-parts
+     _field_offset == p->_field_offset;
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeAryPtr::hash(void) const {
!   return (intptr_t)_ary + TypeOopPtr::hash() + _field_offset.get();
  }
  
  //------------------------------meet-------------------------------------------
  // Compute the MEET of two types.  It returns a new Type object.
  const Type *TypeAryPtr::xmeet_helper(const Type *t) const {

*** 4387,20 ***
      typerr(t);
  
    case OopPtr: {                // Meeting to OopPtrs
      // Found a OopPtr type vs self-AryPtr type
      const TypeOopPtr *tp = t->is_oopptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      int depth = meet_inline_depth(tp->inline_depth());
      const TypePtr* speculative = xmeet_speculative(tp);
      switch (tp->ptr()) {
      case TopPTR:
      case AnyNull: {
        int instance_id = meet_instance_id(InstanceTop);
        return make(ptr, (ptr == Constant ? const_oop() : NULL),
!                   _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
      }
      case BotPTR:
      case NotNull: {
        int instance_id = meet_instance_id(tp->instance_id());
        return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);
--- 4772,20 ---
      typerr(t);
  
    case OopPtr: {                // Meeting to OopPtrs
      // Found a OopPtr type vs self-AryPtr type
      const TypeOopPtr *tp = t->is_oopptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      int depth = meet_inline_depth(tp->inline_depth());
      const TypePtr* speculative = xmeet_speculative(tp);
      switch (tp->ptr()) {
      case TopPTR:
      case AnyNull: {
        int instance_id = meet_instance_id(InstanceTop);
        return make(ptr, (ptr == Constant ? const_oop() : NULL),
!                   _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
      }
      case BotPTR:
      case NotNull: {
        int instance_id = meet_instance_id(tp->instance_id());
        return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);

*** 4410,11 ***
    }
  
    case AnyPtr: {                // Meeting two AnyPtrs
      // Found an AnyPtr type vs self-AryPtr type
      const TypePtr *tp = t->is_ptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      const TypePtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      switch (tp->ptr()) {
      case TopPTR:
--- 4795,11 ---
    }
  
    case AnyPtr: {                // Meeting two AnyPtrs
      // Found an AnyPtr type vs self-AryPtr type
      const TypePtr *tp = t->is_ptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      const TypePtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      switch (tp->ptr()) {
      case TopPTR:

*** 4426,11 ***
        if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth);
        // else fall through to AnyNull
      case AnyNull: {
        int instance_id = meet_instance_id(InstanceTop);
        return make(ptr, (ptr == Constant ? const_oop() : NULL),
!                   _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
      }
      default: ShouldNotReachHere();
      }
    }
  
--- 4811,11 ---
        if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth);
        // else fall through to AnyNull
      case AnyNull: {
        int instance_id = meet_instance_id(InstanceTop);
        return make(ptr, (ptr == Constant ? const_oop() : NULL),
!                   _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
      }
      default: ShouldNotReachHere();
      }
    }
  

*** 4440,22 ***
    case AryKlassPtr:
    case RawPtr: return TypePtr::BOTTOM;
  
    case AryPtr: {                // Meeting 2 references?
      const TypeAryPtr *tap = t->is_aryptr();
!     int off = meet_offset(tap->offset());
      const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary();
      PTR ptr = meet_ptr(tap->ptr());
      int instance_id = meet_instance_id(tap->instance_id());
      const TypePtr* speculative = xmeet_speculative(tap);
      int depth = meet_inline_depth(tap->inline_depth());
  
      ciKlass* res_klass = NULL;
      bool res_xk = false;
!     const Type* elem = tary->_elem;
!     if (meet_aryptr(ptr, elem, this->klass(), tap->klass(), this->klass_is_exact(), tap->klass_is_exact(), this->ptr(), tap->ptr(), res_klass, res_xk) == NOT_SUBTYPE) {
        instance_id = InstanceBot;
      }
  
      ciObject* o = NULL;             // Assume not constant when done
      ciObject* this_oop = const_oop();
      ciObject* tap_oop = tap->const_oop();
--- 4825,40 ---
    case AryKlassPtr:
    case RawPtr: return TypePtr::BOTTOM;
  
    case AryPtr: {                // Meeting 2 references?
      const TypeAryPtr *tap = t->is_aryptr();
!     Offset off = meet_offset(tap->offset());
+     Offset field_off = meet_field_offset(tap->field_offset());
      const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary();
      PTR ptr = meet_ptr(tap->ptr());
      int instance_id = meet_instance_id(tap->instance_id());
      const TypePtr* speculative = xmeet_speculative(tap);
      int depth = meet_inline_depth(tap->inline_depth());
  
      ciKlass* res_klass = NULL;
      bool res_xk = false;
!     bool res_not_flat = false;
!     bool res_not_null_free = false;
+     const Type* res_elem = NULL;
+     if (meet_aryptr(ptr, _ary->_elem, tap->_ary->_elem, this->klass(), tap->klass(),
+                     this->klass_is_exact(), tap->klass_is_exact(), this->ptr(), tap->ptr(),
+                     this->is_not_flat(), tap->is_not_flat(),
+                     this->is_not_null_free(), tap->is_not_null_free(),
+                     res_elem, res_klass, res_xk, res_not_flat, res_not_null_free) == NOT_SUBTYPE) {
        instance_id = InstanceBot;
+     } else if (klass() != NULL && tap->klass() != NULL && klass()->is_flat_array_klass() != tap->klass()->is_flat_array_klass()) {
+       // Meeting flattened inline type array with non-flattened array. Adjust (field) offset accordingly.
+       if (tary->_elem->isa_inlinetype()) {
+         // Result is flattened
+         off = Offset(is_flat() ? offset() : tap->offset());
+         field_off = is_flat() ? field_offset() : tap->field_offset();
+       } else if (tary->_elem->make_oopptr() != NULL && tary->_elem->make_oopptr()->isa_instptr() && below_centerline(ptr)) {
+         // Result is non-flattened
+         off = Offset(flattened_offset()).meet(Offset(tap->flattened_offset()));
+         field_off = Offset::bottom;
+       }
      }
  
      ciObject* o = NULL;             // Assume not constant when done
      ciObject* this_oop = const_oop();
      ciObject* tap_oop = tap->const_oop();

*** 4469,34 ***
          o = this_oop;
        } else {
          ptr = NotNull;
        }
      }
!     return make(ptr, o, TypeAry::make(elem, tary->_size, tary->_stable), res_klass, res_xk, off, instance_id, speculative, depth);
    }
  
    // All arrays inherit from Object class
    case InstPtr: {
      const TypeInstPtr *tp = t->is_instptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      int instance_id = meet_instance_id(tp->instance_id());
      const TypePtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      switch (ptr) {
      case TopPTR:
      case AnyNull:                // Fall 'down' to dual of object klass
        // For instances when a subclass meets a superclass we fall
        // below the centerline when the superclass is exact. We need to
        // do the same here.
!       if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
!         return make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
        } else {
          // cannot subclass, so the meet has to fall badly below the centerline
          ptr = NotNull;
          instance_id = InstanceBot;
!         return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
        }
      case Constant:
      case NotNull:
      case BotPTR:                // Fall down to object klass
        // LCA is object_klass, but if we subclass from the top we can do better
--- 4872,34 ---
          o = this_oop;
        } else {
          ptr = NotNull;
        }
      }
!     return make(ptr, o, TypeAry::make(res_elem, tary->_size, tary->_stable, res_not_flat, res_not_null_free), res_klass, res_xk, off, field_off, instance_id, speculative, depth);
    }
  
    // All arrays inherit from Object class
    case InstPtr: {
      const TypeInstPtr *tp = t->is_instptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      int instance_id = meet_instance_id(tp->instance_id());
      const TypePtr* speculative = xmeet_speculative(tp);
      int depth = meet_inline_depth(tp->inline_depth());
      switch (ptr) {
      case TopPTR:
      case AnyNull:                // Fall 'down' to dual of object klass
        // For instances when a subclass meets a superclass we fall
        // below the centerline when the superclass is exact. We need to
        // do the same here.
!       if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact() && !tp->flatten_array()) {
!         return make(ptr, _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
        } else {
          // cannot subclass, so the meet has to fall badly below the centerline
          ptr = NotNull;
          instance_id = InstanceBot;
!         return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, false, instance_id, speculative, depth);
        }
      case Constant:
      case NotNull:
      case BotPTR:                // Fall down to object klass
        // LCA is object_klass, but if we subclass from the top we can do better

*** 4504,48 ***
          // If 'tp'  is above the centerline and it is Object class
          // then we can subclass in the Java class hierarchy.
          // For instances when a subclass meets a superclass we fall
          // below the centerline when the superclass is exact. We need
          // to do the same here.
!         if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
            // that is, my array type is a subtype of 'tp' klass
            return make(ptr, (ptr == Constant ? const_oop() : NULL),
!                       _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
          }
        }
        // The other case cannot happen, since t cannot be a subtype of an array.
        // The meet falls down to Object class below centerline.
        if (ptr == Constant) {
           ptr = NotNull;
        }
        if (instance_id > 0) {
          instance_id = InstanceBot;
        }
!       return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
      default: typerr(t);
      }
    }
    }
    return this;                  // Lint noise
  }
  
  
! TypePtr::MeetResult TypePtr::meet_aryptr(PTR& ptr, const Type*& elem, ciKlass* this_klass, ciKlass* tap_klass, bool this_xk, bool tap_xk, PTR this_ptr, PTR tap_ptr, ciKlass*& res_klass, bool& res_xk) {
    res_klass = NULL;
    MeetResult result = SUBTYPE;
!   if (elem->isa_int()) {
      // Integral array element types have irrelevant lattice relations.
      // It is the klass that determines array layout, not the element type.
!     if (this_klass == NULL)
        res_klass = tap_klass;
!     else if (tap_klass == NULL || tap_klass == this_klass) {
        res_klass = this_klass;
      } else {
        // Something like byte[int+] meets char[int+].
        // This must fall to bottom, not (int[-128..65535])[int+].
        // instance_id = InstanceBot;
!       elem = Type::BOTTOM;
        result = NOT_SUBTYPE;
      }
    } else // Non integral arrays.
      // Must fall to bottom if exact klasses in upper lattice
      // are not equal or super klass is exact.
--- 4907,71 ---
          // If 'tp'  is above the centerline and it is Object class
          // then we can subclass in the Java class hierarchy.
          // For instances when a subclass meets a superclass we fall
          // below the centerline when the superclass is exact. We need
          // to do the same here.
!         if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact() && !tp->flatten_array()) {
            // that is, my array type is a subtype of 'tp' klass
            return make(ptr, (ptr == Constant ? const_oop() : NULL),
!                       _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
          }
        }
        // The other case cannot happen, since t cannot be a subtype of an array.
        // The meet falls down to Object class below centerline.
        if (ptr == Constant) {
           ptr = NotNull;
        }
        if (instance_id > 0) {
          instance_id = InstanceBot;
        }
!       return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, false, instance_id, speculative, depth);
      default: typerr(t);
      }
    }
+ 
+   case InlineType: {
+     const TypeInlineType* tv = t->is_inlinetype();
+     if (above_centerline(ptr())) {
+       return TypeInstPtr::NOTNULL;
+     } else {
+       PTR ptr = this->_ptr;
+       if (ptr == Constant) {
+         ptr = NotNull;
+       }
+       return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass());
+     }
+   }
    }
    return this;                  // Lint noise
  }
  
  
! TypePtr::MeetResult TypePtr::meet_aryptr(PTR& ptr, const Type* this_elem, const Type* tap_elem,
+                                          ciKlass* this_klass, ciKlass* tap_klass,
+                                          bool this_xk, bool tap_xk, PTR this_ptr, PTR tap_ptr,
+                                          bool this_not_flat, bool tap_not_flat,
+                                          bool this_not_null_free, bool tap_not_null_free,
+                                          const Type*& res_elem, ciKlass*& res_klass,
+                                          bool& res_xk, bool& res_not_flat, bool& res_not_null_free) {
    res_klass = NULL;
    MeetResult result = SUBTYPE;
!   res_elem = this_elem->meet(tap_elem);
+   res_not_flat = this_not_flat && tap_not_flat;
+   res_not_null_free = this_not_null_free && tap_not_null_free;
+ 
+   if (res_elem->isa_int()) {
      // Integral array element types have irrelevant lattice relations.
      // It is the klass that determines array layout, not the element type.
!     if (this_klass == NULL) {
        res_klass = tap_klass;
!     } else if (tap_klass == NULL || tap_klass == this_klass) {
        res_klass = this_klass;
      } else {
        // Something like byte[int+] meets char[int+].
        // This must fall to bottom, not (int[-128..65535])[int+].
        // instance_id = InstanceBot;
!       res_elem = Type::BOTTOM;
        result = NOT_SUBTYPE;
      }
    } else // Non integral arrays.
      // Must fall to bottom if exact klasses in upper lattice
      // are not equal or super klass is exact.

*** 4556,12 ***
          ((tap_xk && this_xk) ||
           // 'tap'  is exact and super or unrelated:
           (tap_xk && !tap_klass->is_subtype_of(this_klass)) ||
           // 'this' is exact and super or unrelated:
           (this_xk && !this_klass->is_subtype_of(tap_klass)))) {
!       if (above_centerline(ptr) || (elem->make_ptr() && above_centerline(elem->make_ptr()->_ptr))) {
!         elem = Type::BOTTOM;
        }
        ptr = NotNull;
        res_xk = false;
        return NOT_SUBTYPE;
      }
--- 4982,13 ---
          ((tap_xk && this_xk) ||
           // 'tap'  is exact and super or unrelated:
           (tap_xk && !tap_klass->is_subtype_of(this_klass)) ||
           // 'this' is exact and super or unrelated:
           (this_xk && !this_klass->is_subtype_of(tap_klass)))) {
!       if (above_centerline(ptr) || (res_elem->make_ptr() && above_centerline(res_elem->make_ptr()->_ptr)) ||
!           res_elem->isa_inlinetype()) {
+         res_elem = Type::BOTTOM;
        }
        ptr = NotNull;
        res_xk = false;
        return NOT_SUBTYPE;
      }

*** 4571,48 ***
      case AnyNull:
      case TopPTR:
        // Compute new klass on demand, do not use tap->_klass
        if (below_centerline(this_ptr)) {
          res_xk = this_xk;
        } else {
          res_xk = (tap_xk || this_xk);
        }
!       return result;
      case Constant: {
        if (this_ptr == Constant) {
!           res_xk = true;
        } else if(above_centerline(this_ptr)) {
          res_xk = true;
        } else {
          // Only precise for identical arrays
          res_xk = this_xk && (this_klass == tap_klass);
        }
!       return result;
      }
      case NotNull:
      case BotPTR:
        // Compute new klass on demand, do not use tap->_klass
        if (above_centerline(this_ptr)) {
          res_xk = tap_xk;
        } else {
          res_xk = (tap_xk && this_xk) &&
            (this_klass == tap_klass); // Only precise for identical arrays
        }
!       return result;
      default:  {
        ShouldNotReachHere();
        return result;
      }
    }
    return result;
  }
  
  
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const Type *TypeAryPtr::xdual() const {
!   return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth());
  }
  
  //----------------------interface_vs_oop---------------------------------------
  #ifdef ASSERT
  bool TypeAryPtr::interface_vs_oop(const Type *t) const {
--- 4998,64 ---
      case AnyNull:
      case TopPTR:
        // Compute new klass on demand, do not use tap->_klass
        if (below_centerline(this_ptr)) {
          res_xk = this_xk;
+         if (this_elem->isa_inlinetype()) {
+           res_elem = this_elem;
+         }
        } else {
          res_xk = (tap_xk || this_xk);
        }
!       break;
      case Constant: {
        if (this_ptr == Constant) {
!         res_xk = true;
        } else if(above_centerline(this_ptr)) {
          res_xk = true;
        } else {
          // Only precise for identical arrays
          res_xk = this_xk && (this_klass == tap_klass);
        }
!       break;
      }
      case NotNull:
      case BotPTR:
        // Compute new klass on demand, do not use tap->_klass
        if (above_centerline(this_ptr)) {
          res_xk = tap_xk;
+         if (tap_elem->isa_inlinetype()) {
+           res_elem = tap_elem;
+         }
        } else {
          res_xk = (tap_xk && this_xk) &&
            (this_klass == tap_klass); // Only precise for identical arrays
        }
!       break;
      default:  {
        ShouldNotReachHere();
        return result;
      }
    }
+ 
    return result;
  }
  
  
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const Type *TypeAryPtr::xdual() const {
!   return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(), _klass, _klass_is_exact, dual_offset(), dual_field_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth());
+ }
+ 
+ Type::Offset TypeAryPtr::meet_field_offset(const Type::Offset offset) const {
+   return _field_offset.meet(offset);
+ }
+ 
+ //------------------------------dual_offset------------------------------------
+ Type::Offset TypeAryPtr::dual_field_offset() const {
+   return _field_offset.dual();
  }
  
  //----------------------interface_vs_oop---------------------------------------
  #ifdef ASSERT
  bool TypeAryPtr::interface_vs_oop(const Type *t) const {

*** 4645,20 ***
      break;
    default:
      break;
    }
  
!   if( _offset != 0 ) {
      int header_size = objArrayOopDesc::header_size() * wordSize;
!     if( _offset == OffsetTop )       st->print("+undefined");
!     else if( _offset == OffsetBot )  st->print("+any");
!     else if( _offset < header_size ) st->print("+%d", _offset);
      else {
        BasicType basic_elem_type = elem()->basic_type();
        int array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
        int elem_size = type2aelembytes(basic_elem_type);
!       st->print("[%d]", (_offset - array_base)/elem_size);
      }
    }
    st->print(" *");
    if (_instance_id == InstanceTop)
      st->print(",iid=top");
--- 5088,25 ---
      break;
    default:
      break;
    }
  
!   if (is_flat()) {
+     st->print("(");
+     _field_offset.dump2(st);
+     st->print(")");
+   }
+   if (offset() != 0) {
      int header_size = objArrayOopDesc::header_size() * wordSize;
!     if( _offset == Offset::top )       st->print("+undefined");
!     else if( _offset == Offset::bottom )  st->print("+any");
!     else if( offset() < header_size ) st->print("+%d", offset());
      else {
        BasicType basic_elem_type = elem()->basic_type();
        int array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type);
        int elem_size = type2aelembytes(basic_elem_type);
!       st->print("[%d]", (offset() - array_base)/elem_size);
      }
    }
    st->print(" *");
    if (_instance_id == InstanceTop)
      st->print(",iid=top");

*** 4675,35 ***
    return TypeOopPtr::empty();
  }
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const {
!   return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth);
  }
  
  const Type *TypeAryPtr::remove_speculative() const {
    if (_speculative == NULL) {
      return this;
    }
    assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
!   return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL, _inline_depth);
  }
  
  const TypePtr *TypeAryPtr::with_inline_depth(int depth) const {
    if (!UseInlineDepthForSpeculativeTypes) {
      return this;
    }
!   return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, _speculative, depth);
  }
  
  const TypePtr *TypeAryPtr::with_instance_id(int instance_id) const {
    assert(is_known_instance(), "should be known");
!   return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
  }
  
  //=============================================================================
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeNarrowPtr::hash(void) const {
    return _ptrtype->hash() + 7;
  }
--- 5123,99 ---
    return TypeOopPtr::empty();
  }
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const {
!   return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _field_offset, _instance_id, add_offset_speculative(offset), _inline_depth, _is_autobox_cache);
  }
  
  const Type *TypeAryPtr::remove_speculative() const {
    if (_speculative == NULL) {
      return this;
    }
    assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
!   return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _field_offset, _instance_id, NULL, _inline_depth, _is_autobox_cache);
+ }
+ 
+ const Type* TypeAryPtr::cleanup_speculative() const {
+   if (speculative() == NULL) {
+     return this;
+   }
+   // Keep speculative part if it contains information about flat-/nullability
+   const TypeAryPtr* spec_aryptr = speculative()->isa_aryptr();
+   if (spec_aryptr != NULL && (spec_aryptr->is_not_flat() || spec_aryptr->is_not_null_free())) {
+     return this;
+   }
+   return TypeOopPtr::cleanup_speculative();
  }
  
  const TypePtr *TypeAryPtr::with_inline_depth(int depth) const {
    if (!UseInlineDepthForSpeculativeTypes) {
      return this;
    }
!   return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _field_offset, _instance_id, _speculative, depth, _is_autobox_cache);
+ }
+ 
+ const TypeAryPtr* TypeAryPtr::with_field_offset(int offset) const {
+   return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, Offset(offset), _instance_id, _speculative, _inline_depth, _is_autobox_cache);
+ }
+ 
+ const TypePtr* TypeAryPtr::add_field_offset_and_offset(intptr_t offset) const {
+   int adj = 0;
+   if (offset != Type::OffsetBot && offset != Type::OffsetTop) {
+     const Type* elemtype = elem();
+     if (elemtype->isa_inlinetype()) {
+       if (_offset.get() != OffsetBot && _offset.get() != OffsetTop) {
+         adj = _offset.get();
+         offset += _offset.get();
+       }
+       uint header = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
+       if (_field_offset.get() != OffsetBot && _field_offset.get() != OffsetTop) {
+         offset += _field_offset.get();
+         if (_offset.get() == OffsetBot || _offset.get() == OffsetTop) {
+           offset += header;
+         }
+       }
+       if (offset >= (intptr_t)header || offset < 0) {
+         // Try to get the field of the inline type array element we are pointing to
+         ciKlass* arytype_klass = klass();
+         ciFlatArrayKlass* vak = arytype_klass->as_flat_array_klass();
+         ciInlineKlass* vk = vak->element_klass()->as_inline_klass();
+         int shift = vak->log2_element_size();
+         int mask = (1 << shift) - 1;
+         intptr_t field_offset = ((offset - header) & mask);
+         ciField* field = vk->get_field_by_offset(field_offset + vk->first_field_offset(), false);
+         if (field == NULL) {
+           // This may happen with nested AddP(base, AddP(base, base, offset), longcon(16))
+           return add_offset(offset);
+         } else {
+           return with_field_offset(field_offset)->add_offset(offset - field_offset - adj);
+         }
+       }
+     }
+   }
+   return add_offset(offset - adj);
+ }
+ 
+ // Return offset incremented by field_offset for flattened inline type arrays
+ const int TypeAryPtr::flattened_offset() const {
+   int offset = _offset.get();
+   if (offset != Type::OffsetBot && offset != Type::OffsetTop &&
+       _field_offset != Offset::bottom && _field_offset != Offset::top) {
+     offset += _field_offset.get();
+   }
+   return offset;
  }
  
  const TypePtr *TypeAryPtr::with_instance_id(int instance_id) const {
    assert(is_known_instance(), "should be known");
!   return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _field_offset, instance_id, _speculative, _inline_depth);
  }
  
  //=============================================================================
  
+ 
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeNarrowPtr::hash(void) const {
    return _ptrtype->hash() + 7;
  }

*** 4790,16 ***
    case KlassPtr:
    case InstKlassPtr:
    case AryKlassPtr:
    case NarrowOop:
    case NarrowKlass:
- 
    case Bottom:                  // Ye Olde Default
      return Type::BOTTOM;
    case Top:
      return this;
  
    default:                      // All else is a mistake
      typerr(t);
  
    } // End of switch
  
--- 5302,18 ---
    case KlassPtr:
    case InstKlassPtr:
    case AryKlassPtr:
    case NarrowOop:
    case NarrowKlass:
    case Bottom:                  // Ye Olde Default
      return Type::BOTTOM;
    case Top:
      return this;
  
+   case InlineType:
+     return t->xmeet(this);
+ 
    default:                      // All else is a mistake
      typerr(t);
  
    } // End of switch
  

*** 4874,11 ***
  // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  // constants
  bool TypeMetadataPtr::singleton(void) const {
    // detune optimizer to not generate constant metadata + constant offset as a constant!
    // TopPTR, Null, AnyNull, Constant are all singletons
!   return (_offset == 0) && !below_centerline(_ptr);
  }
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypeMetadataPtr::add_offset( intptr_t offset ) const {
    return make( _ptr, _metadata, xadd_offset(offset));
--- 5388,11 ---
  // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  // constants
  bool TypeMetadataPtr::singleton(void) const {
    // detune optimizer to not generate constant metadata + constant offset as a constant!
    // TopPTR, Null, AnyNull, Constant are all singletons
!   return (offset() == 0) && !below_centerline(_ptr);
  }
  
  //------------------------------add_offset-------------------------------------
  const TypePtr *TypeMetadataPtr::add_offset( intptr_t offset ) const {
    return make( _ptr, _metadata, xadd_offset(offset));

*** 4894,13 ***
  }
  
   //------------------------------get_con----------------------------------------
  intptr_t TypeMetadataPtr::get_con() const {
    assert( _ptr == Null || _ptr == Constant, "" );
!   assert( _offset >= 0, "" );
  
!   if (_offset != 0) {
      // After being ported to the compiler interface, the compiler no longer
      // directly manipulates the addresses of oops.  Rather, it only has a pointer
      // to a handle at compile time.  This handle is embedded in the generated
      // code and dereferenced at the time the nmethod is made.  Until that time,
      // it is not reasonable to do arithmetic with the addresses of oops (we don't
--- 5408,13 ---
  }
  
   //------------------------------get_con----------------------------------------
  intptr_t TypeMetadataPtr::get_con() const {
    assert( _ptr == Null || _ptr == Constant, "" );
!   assert(offset() >= 0, "");
  
!   if (offset() != 0) {
      // After being ported to the compiler interface, the compiler no longer
      // directly manipulates the addresses of oops.  Rather, it only has a pointer
      // to a handle at compile time.  This handle is embedded in the generated
      // code and dereferenced at the time the nmethod is made.  Until that time,
      // it is not reasonable to do arithmetic with the addresses of oops (we don't

*** 4947,11 ***
      typerr(t);
  
    case AnyPtr: {
      // Found an AnyPtr type vs self-OopPtr type
      const TypePtr *tp = t->is_ptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      switch (tp->ptr()) {
      case Null:
        if (ptr == Null)  return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
        // else fall through:
--- 5461,11 ---
      typerr(t);
  
    case AnyPtr: {
      // Found an AnyPtr type vs self-OopPtr type
      const TypePtr *tp = t->is_ptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      switch (tp->ptr()) {
      case Null:
        if (ptr == Null)  return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
        // else fall through:

*** 4975,11 ***
    case AryPtr:
      return TypePtr::BOTTOM;     // Oop meet raw is not well defined
  
    case MetadataPtr: {
      const TypeMetadataPtr *tp = t->is_metadataptr();
!     int offset = meet_offset(tp->offset());
      PTR tptr = tp->ptr();
      PTR ptr = meet_ptr(tptr);
      ciMetadata* md = (tptr == TopPTR) ? metadata() : tp->metadata();
      if (tptr == TopPTR || _ptr == TopPTR ||
          metadata()->equals(tp->metadata())) {
--- 5489,11 ---
    case AryPtr:
      return TypePtr::BOTTOM;     // Oop meet raw is not well defined
  
    case MetadataPtr: {
      const TypeMetadataPtr *tp = t->is_metadataptr();
!     Offset offset = meet_offset(tp->offset());
      PTR tptr = tp->ptr();
      PTR ptr = meet_ptr(tptr);
      ciMetadata* md = (tptr == TopPTR) ? metadata() : tp->metadata();
      if (tptr == TopPTR || _ptr == TopPTR ||
          metadata()->equals(tp->metadata())) {

*** 5008,38 ***
  //------------------------------dump2------------------------------------------
  #ifndef PRODUCT
  void TypeMetadataPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
    st->print("metadataptr:%s", ptr_msg[_ptr]);
    if( metadata() ) st->print(INTPTR_FORMAT, p2i(metadata()));
!   switch( _offset ) {
    case OffsetTop: st->print("+top"); break;
    case OffsetBot: st->print("+any"); break;
    case         0: break;
!   default:        st->print("+%d",_offset); break;
    }
  }
  #endif
  
  
  //=============================================================================
  // Convenience common pre-built type.
  const TypeMetadataPtr *TypeMetadataPtr::BOTTOM;
  
! TypeMetadataPtr::TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset):
    TypePtr(MetadataPtr, ptr, offset), _metadata(metadata) {
  }
  
  const TypeMetadataPtr* TypeMetadataPtr::make(ciMethod* m) {
!   return make(Constant, m, 0);
  }
  const TypeMetadataPtr* TypeMetadataPtr::make(ciMethodData* m) {
!   return make(Constant, m, 0);
  }
  
  //------------------------------make-------------------------------------------
  // Create a meta data constant
! const TypeMetadataPtr *TypeMetadataPtr::make(PTR ptr, ciMetadata* m, int offset) {
    assert(m == NULL || !m->is_klass(), "wrong type");
    return (TypeMetadataPtr*)(new TypeMetadataPtr(ptr, m, offset))->hashcons();
  }
  
  
--- 5522,38 ---
  //------------------------------dump2------------------------------------------
  #ifndef PRODUCT
  void TypeMetadataPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
    st->print("metadataptr:%s", ptr_msg[_ptr]);
    if( metadata() ) st->print(INTPTR_FORMAT, p2i(metadata()));
!   switch (offset()) {
    case OffsetTop: st->print("+top"); break;
    case OffsetBot: st->print("+any"); break;
    case         0: break;
!   default:        st->print("+%d",offset()); break;
    }
  }
  #endif
  
  
  //=============================================================================
  // Convenience common pre-built type.
  const TypeMetadataPtr *TypeMetadataPtr::BOTTOM;
  
! TypeMetadataPtr::TypeMetadataPtr(PTR ptr, ciMetadata* metadata, Offset offset):
    TypePtr(MetadataPtr, ptr, offset), _metadata(metadata) {
  }
  
  const TypeMetadataPtr* TypeMetadataPtr::make(ciMethod* m) {
!   return make(Constant, m, Offset(0));
  }
  const TypeMetadataPtr* TypeMetadataPtr::make(ciMethodData* m) {
!   return make(Constant, m, Offset(0));
  }
  
  //------------------------------make-------------------------------------------
  // Create a meta data constant
! const TypeMetadataPtr* TypeMetadataPtr::make(PTR ptr, ciMetadata* m, Offset offset) {
    assert(m == NULL || !m->is_klass(), "wrong type");
    return (TypeMetadataPtr*)(new TypeMetadataPtr(ptr, m, offset))->hashcons();
  }
  
  

*** 5050,30 ***
      elem = elem->make_oopptr()->as_klass_type(try_for_exact);
      if (elem->is_klassptr()->klass_is_exact()) {
        xk = true;
      }
    }
!   return TypeAryKlassPtr::make(xk ? TypePtr::Constant : TypePtr::NotNull, elem, klass(), 0);
  }
  
  const TypeKlassPtr* TypeKlassPtr::make(ciKlass *klass) {
    if (klass->is_instance_klass()) {
      return TypeInstKlassPtr::make(klass);
    }
    return TypeAryKlassPtr::make(klass);
  }
  
! const TypeKlassPtr* TypeKlassPtr::make(PTR ptr, ciKlass* klass, int offset) {
    if (klass->is_instance_klass()) {
      return TypeInstKlassPtr::make(ptr, klass, offset);
    }
!   return TypeAryKlassPtr::make(ptr, klass, offset);
  }
  
- 
  //------------------------------TypeKlassPtr-----------------------------------
! TypeKlassPtr::TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, int offset)
    : TypePtr(t, ptr, offset), _klass(klass) {
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
--- 5564,29 ---
      elem = elem->make_oopptr()->as_klass_type(try_for_exact);
      if (elem->is_klassptr()->klass_is_exact()) {
        xk = true;
      }
    }
!   return TypeAryKlassPtr::make(xk ? TypePtr::Constant : TypePtr::NotNull, elem, klass(), Offset(0), is_not_flat(), is_not_null_free(), is_null_free());
  }
  
  const TypeKlassPtr* TypeKlassPtr::make(ciKlass *klass) {
    if (klass->is_instance_klass()) {
      return TypeInstKlassPtr::make(klass);
    }
    return TypeAryKlassPtr::make(klass);
  }
  
! const TypeKlassPtr* TypeKlassPtr::make(PTR ptr, ciKlass* klass, Offset offset) {
    if (klass->is_instance_klass()) {
      return TypeInstKlassPtr::make(ptr, klass, offset);
    }
!   return TypeAryKlassPtr::make(klass, ptr, offset);
  }
  
  //------------------------------TypeKlassPtr-----------------------------------
! TypeKlassPtr::TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, Offset offset)
    : TypePtr(t, ptr, offset), _klass(klass) {
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations

*** 5093,11 ***
  // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  // constants
  bool TypeKlassPtr::singleton(void) const {
    // detune optimizer to not generate constant klass + constant offset as a constant!
    // TopPTR, Null, AnyNull, Constant are all singletons
!   return (_offset == 0) && !below_centerline(_ptr);
  }
  
  // Do not allow interface-vs.-noninterface joins to collapse to top.
  const Type *TypeKlassPtr::filter_helper(const Type *kills, bool include_speculative) const {
    // logic here mirrors the one from TypeOopPtr::filter. See comments
--- 5606,11 ---
  // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  // constants
  bool TypeKlassPtr::singleton(void) const {
    // detune optimizer to not generate constant klass + constant offset as a constant!
    // TopPTR, Null, AnyNull, Constant are all singletons
!   return (offset() == 0) && !below_centerline(_ptr);
  }
  
  // Do not allow interface-vs.-noninterface joins to collapse to top.
  const Type *TypeKlassPtr::filter_helper(const Type *kills, bool include_speculative) const {
    // logic here mirrors the one from TypeOopPtr::filter. See comments

*** 5105,11 ***
    const Type* ft = join_helper(kills, include_speculative);
    const TypeKlassPtr* ftkp = ft->isa_instklassptr();
    const TypeKlassPtr* ktkp = kills->isa_instklassptr();
  
    if (ft->empty()) {
!     if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface())
        return kills;             // Uplift to interface
  
      return Type::TOP;           // Canonical empty value
    }
  
--- 5618,11 ---
    const Type* ft = join_helper(kills, include_speculative);
    const TypeKlassPtr* ftkp = ft->isa_instklassptr();
    const TypeKlassPtr* ktkp = kills->isa_instklassptr();
  
    if (ft->empty()) {
!     if (!empty() && ktkp != NULL && ktkp->is_loaded() && ktkp->klass()->is_interface())
        return kills;             // Uplift to interface
  
      return Type::TOP;           // Canonical empty value
    }
  

*** 5126,13 ***
  }
  
  //------------------------------get_con----------------------------------------
  intptr_t TypeKlassPtr::get_con() const {
    assert( _ptr == Null || _ptr == Constant, "" );
!   assert( _offset >= 0, "" );
  
!   if (_offset != 0) {
      // After being ported to the compiler interface, the compiler no longer
      // directly manipulates the addresses of oops.  Rather, it only has a pointer
      // to a handle at compile time.  This handle is embedded in the generated
      // code and dereferenced at the time the nmethod is made.  Until that time,
      // it is not reasonable to do arithmetic with the addresses of oops (we don't
--- 5639,13 ---
  }
  
  //------------------------------get_con----------------------------------------
  intptr_t TypeKlassPtr::get_con() const {
    assert( _ptr == Null || _ptr == Constant, "" );
!   assert( offset() >= 0, "" );
  
!   if (offset() != 0) {
      // After being ported to the compiler interface, the compiler no longer
      // directly manipulates the addresses of oops.  Rather, it only has a pointer
      // to a handle at compile time.  This handle is embedded in the generated
      // code and dereferenced at the time the nmethod is made.  Until that time,
      // it is not reasonable to do arithmetic with the addresses of oops (we don't

*** 5146,11 ***
  }
  
  //------------------------------dump2------------------------------------------
  // Dump Klass Type
  #ifndef PRODUCT
! void TypeKlassPtr::dump2(Dict & d, uint depth, outputStream *st) const {
    switch(_ptr) {
    case Constant:
      st->print("precise ");
    case NotNull:
      {
--- 5659,11 ---
  }
  
  //------------------------------dump2------------------------------------------
  // Dump Klass Type
  #ifndef PRODUCT
! void TypeInstKlassPtr::dump2(Dict & d, uint depth, outputStream *st) const {
    switch(_ptr) {
    case Constant:
      st->print("precise ");
    case NotNull:
      {

*** 5169,17 ***
      if (_ptr == Constant) st->print(":exact");
      break;
    default:
      break;
    }
! 
!   if (_offset) {               // Dump offset, if any
-     if (_offset == OffsetBot)      { st->print("+any"); }
-     else if (_offset == OffsetTop) { st->print("+unknown"); }
-     else                            { st->print("+%d", _offset); }
    }
! 
    st->print(" *");
  }
  #endif
  
  //=============================================================================
--- 5682,14 ---
      if (_ptr == Constant) st->print(":exact");
      break;
    default:
      break;
    }
!   if (Verbose) {
!     if (_flatten_array) st->print(":flatten array");
    }
!   _offset.dump2(st);
    st->print(" *");
  }
  #endif
  
  //=============================================================================

*** 5191,39 ***
  
  bool TypeInstKlassPtr::eq(const Type *t) const {
    const TypeKlassPtr *p = t->is_klassptr();
    return
      klass()->equals(p->klass()) &&
      TypeKlassPtr::eq(p);
  }
  
  int TypeInstKlassPtr::hash(void) const {
!   return java_add((jint)klass()->hash(), TypeKlassPtr::hash());
  }
  
! const TypeInstKlassPtr *TypeInstKlassPtr::make(PTR ptr, ciKlass* k, int offset) {
    TypeInstKlassPtr *r =
!     (TypeInstKlassPtr*)(new TypeInstKlassPtr(ptr, k, offset))->hashcons();
  
    return r;
  }
  
  //------------------------------add_offset-------------------------------------
  // Access internals of klass object
  const TypePtr *TypeInstKlassPtr::add_offset( intptr_t offset ) const {
!   return make( _ptr, klass(), xadd_offset(offset) );
  }
  
  const TypeKlassPtr *TypeInstKlassPtr::with_offset(intptr_t offset) const {
!   return make(_ptr, klass(), offset);
  }
  
  //------------------------------cast_to_ptr_type-------------------------------
  const TypePtr* TypeInstKlassPtr::cast_to_ptr_type(PTR ptr) const {
    assert(_base == InstKlassPtr, "subclass must override cast_to_ptr_type");
    if( ptr == _ptr ) return this;
!   return make(ptr, _klass, _offset);
  }
  
  
  bool TypeInstKlassPtr::must_be_exact() const {
    if (!_klass->is_loaded())  return false;
--- 5701,42 ---
  
  bool TypeInstKlassPtr::eq(const Type *t) const {
    const TypeKlassPtr *p = t->is_klassptr();
    return
      klass()->equals(p->klass()) &&
+     flatten_array() == p->flatten_array() &&
      TypeKlassPtr::eq(p);
  }
  
  int TypeInstKlassPtr::hash(void) const {
!   return java_add(java_add((jint)klass()->hash(), TypeKlassPtr::hash()), (jint)flatten_array());
  }
  
! const TypeInstKlassPtr *TypeInstKlassPtr::make(PTR ptr, ciKlass* k, Offset offset, bool flatten_array) {
+   flatten_array = flatten_array || k->flatten_array();
+ 
    TypeInstKlassPtr *r =
!     (TypeInstKlassPtr*)(new TypeInstKlassPtr(ptr, k, offset, flatten_array))->hashcons();
  
    return r;
  }
  
  //------------------------------add_offset-------------------------------------
  // Access internals of klass object
  const TypePtr *TypeInstKlassPtr::add_offset( intptr_t offset ) const {
!   return make(_ptr, klass(), xadd_offset(offset), flatten_array());
  }
  
  const TypeKlassPtr *TypeInstKlassPtr::with_offset(intptr_t offset) const {
!   return make(_ptr, klass(), Offset(offset), flatten_array());
  }
  
  //------------------------------cast_to_ptr_type-------------------------------
  const TypePtr* TypeInstKlassPtr::cast_to_ptr_type(PTR ptr) const {
    assert(_base == InstKlassPtr, "subclass must override cast_to_ptr_type");
    if( ptr == _ptr ) return this;
!   return make(ptr, _klass, _offset, flatten_array());
  }
  
  
  bool TypeInstKlassPtr::must_be_exact() const {
    if (!_klass->is_loaded())  return false;

*** 5235,21 ***
  //-----------------------------cast_to_exactness-------------------------------
  const TypeKlassPtr* TypeInstKlassPtr::cast_to_exactness(bool klass_is_exact) const {
    if (klass_is_exact == (_ptr == Constant)) return this;
    if (must_be_exact()) return this;
    ciKlass* k = klass();
!   return make(klass_is_exact ? Constant : NotNull, k, _offset);
  }
  
  
  //-----------------------------as_instance_type--------------------------------
  // Corresponding type for an instance of the given class.
  // It will be NotNull, and exact if and only if the klass type is exact.
  const TypeOopPtr* TypeInstKlassPtr::as_instance_type() const {
    ciKlass* k = klass();
    bool    xk = klass_is_exact();
!   return TypeInstPtr::make(TypePtr::BotPTR, k, xk, NULL, 0);
  }
  
  //------------------------------xmeet------------------------------------------
  // Compute the MEET of two types, return a new Type object.
  const Type    *TypeInstKlassPtr::xmeet( const Type *t ) const {
--- 5748,21 ---
  //-----------------------------cast_to_exactness-------------------------------
  const TypeKlassPtr* TypeInstKlassPtr::cast_to_exactness(bool klass_is_exact) const {
    if (klass_is_exact == (_ptr == Constant)) return this;
    if (must_be_exact()) return this;
    ciKlass* k = klass();
!   return make(klass_is_exact ? Constant : NotNull, k, _offset, flatten_array());
  }
  
  
  //-----------------------------as_instance_type--------------------------------
  // Corresponding type for an instance of the given class.
  // It will be NotNull, and exact if and only if the klass type is exact.
  const TypeOopPtr* TypeInstKlassPtr::as_instance_type() const {
    ciKlass* k = klass();
    bool    xk = klass_is_exact();
!   return TypeInstPtr::make(TypePtr::BotPTR, k, xk, NULL, Offset(0), flatten_array() && !klass()->is_inlinetype());
  }
  
  //------------------------------xmeet------------------------------------------
  // Compute the MEET of two types, return a new Type object.
  const Type    *TypeInstKlassPtr::xmeet( const Type *t ) const {

*** 5278,19 ***
      typerr(t);
  
    case AnyPtr: {                // Meeting to AnyPtrs
      // Found an AnyPtr type vs self-KlassPtr type
      const TypePtr *tp = t->is_ptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      switch (tp->ptr()) {
      case TopPTR:
        return this;
      case Null:
        if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
      case AnyNull:
!       return make( ptr, klass(), offset );
      case BotPTR:
      case NotNull:
        return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
      default: typerr(t);
      }
--- 5791,19 ---
      typerr(t);
  
    case AnyPtr: {                // Meeting to AnyPtrs
      // Found an AnyPtr type vs self-KlassPtr type
      const TypePtr *tp = t->is_ptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      switch (tp->ptr()) {
      case TopPTR:
        return this;
      case Null:
        if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
      case AnyNull:
!       return make(ptr, klass(), offset, flatten_array());
      case BotPTR:
      case NotNull:
        return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
      default: typerr(t);
      }

*** 5299,11 ***
    case RawPtr:
    case MetadataPtr:
    case OopPtr:
    case AryPtr:                  // Meet with AryPtr
    case InstPtr:                 // Meet with InstPtr
!     return TypePtr::BOTTOM;
  
    //
    //             A-top         }
    //           /   |   \       }  Tops
    //       B-top A-any C-top   }
--- 5812,11 ---
    case RawPtr:
    case MetadataPtr:
    case OopPtr:
    case AryPtr:                  // Meet with AryPtr
    case InstPtr:                 // Meet with InstPtr
!       return TypePtr::BOTTOM;
  
    //
    //             A-top         }
    //           /   |   \       }  Tops
    //       B-top A-any C-top   }

*** 5319,51 ***
    //             A-bot         }
    //
  
    case InstKlassPtr: {  // Meet two KlassPtr types
      const TypeInstKlassPtr *tkls = t->is_instklassptr();
!     int  off     = meet_offset(tkls->offset());
      PTR  ptr     = meet_ptr(tkls->ptr());
      ciKlass* tkls_klass = tkls->klass();
      ciKlass* this_klass  = klass();
      bool tkls_xk = tkls->klass_is_exact();
      bool this_xk  = klass_is_exact();
  
      ciKlass* res_klass = NULL;
      bool res_xk = false;
!     switch(meet_instptr(ptr, this_klass, tkls_klass, this_xk, tkls_xk, this->_ptr, tkls->_ptr, res_klass, res_xk)) {
        case UNLOADED:
          ShouldNotReachHere();
        case SUBTYPE:
        case NOT_SUBTYPE:
        case LCA:
        case QUICK: {
          assert(res_xk == (ptr == Constant), "");
!         const Type* res1 = make(ptr, res_klass, off);
          return res1;
        }
        default:
          ShouldNotReachHere();
      }
    } // End of case KlassPtr
    case AryKlassPtr: {                // All arrays inherit from Object class
      const TypeAryKlassPtr *tp = t->is_aryklassptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
  
      switch (ptr) {
      case TopPTR:
      case AnyNull:                // Fall 'down' to dual of object klass
        // For instances when a subclass meets a superclass we fall
        // below the centerline when the superclass is exact. We need to
        // do the same here.
        if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
!         return TypeAryKlassPtr::make(ptr, tp->elem(), tp->klass(), offset);
        } else {
          // cannot subclass, so the meet has to fall badly below the centerline
          ptr = NotNull;
!         return make(ptr, ciEnv::current()->Object_klass(), offset);
        }
      case Constant:
      case NotNull:
      case BotPTR:                // Fall down to object klass
        // LCA is object_klass, but if we subclass from the top we can do better
--- 5832,55 ---
    //             A-bot         }
    //
  
    case InstKlassPtr: {  // Meet two KlassPtr types
      const TypeInstKlassPtr *tkls = t->is_instklassptr();
!     Offset  off     = meet_offset(tkls->offset());
      PTR  ptr     = meet_ptr(tkls->ptr());
      ciKlass* tkls_klass = tkls->klass();
      ciKlass* this_klass  = klass();
      bool tkls_xk = tkls->klass_is_exact();
      bool this_xk  = klass_is_exact();
+     bool tkls_flatten_array = tkls->flatten_array();
+     bool this_flatten_array  = this->flatten_array();
  
      ciKlass* res_klass = NULL;
      bool res_xk = false;
!     bool res_flatten_array = false;
+     switch(meet_instptr(ptr, this_klass, tkls_klass, this_xk, tkls_xk, this->_ptr, tkls->_ptr,
+                         this_flatten_array, tkls_flatten_array, res_klass, res_xk, res_flatten_array)) {
        case UNLOADED:
          ShouldNotReachHere();
        case SUBTYPE:
        case NOT_SUBTYPE:
        case LCA:
        case QUICK: {
          assert(res_xk == (ptr == Constant), "");
!         const Type* res1 = make(ptr, res_klass, off, res_flatten_array);
          return res1;
        }
        default:
          ShouldNotReachHere();
      }
    } // End of case KlassPtr
    case AryKlassPtr: {                // All arrays inherit from Object class
      const TypeAryKlassPtr *tp = t->is_aryklassptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
  
      switch (ptr) {
      case TopPTR:
      case AnyNull:                // Fall 'down' to dual of object klass
        // For instances when a subclass meets a superclass we fall
        // below the centerline when the superclass is exact. We need to
        // do the same here.
        if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
!         return TypeAryKlassPtr::make(ptr, tp->elem(), tp->klass(), offset, tp->is_not_flat(), tp->is_not_null_free(), tp->null_free());
        } else {
          // cannot subclass, so the meet has to fall badly below the centerline
          ptr = NotNull;
!         return make(ptr, ciEnv::current()->Object_klass(), offset, false);
        }
      case Constant:
      case NotNull:
      case BotPTR:                // Fall down to object klass
        // LCA is object_klass, but if we subclass from the top we can do better

*** 5374,62 ***
          // below the centerline when the superclass is exact. We need
          // to do the same here.
          if (klass()->equals(ciEnv::current()->Object_klass())) {
            // that is, tp's array type is a subtype of my klass
            return TypeAryKlassPtr::make(ptr,
!                                        tp->elem(), tp->klass(), offset);
          }
        }
        // The other case cannot happen, since I cannot be a subtype of an array.
        // The meet falls down to Object class below centerline.
        if( ptr == Constant )
           ptr = NotNull;
!       return make(ptr, ciEnv::current()->Object_klass(), offset);
      default: typerr(t);
      }
    }
  
    } // End of switch
    return this;                  // Return the double constant
  }
  
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const Type    *TypeInstKlassPtr::xdual() const {
!   return new TypeInstKlassPtr(dual_ptr(), klass(), dual_offset());
  }
  
! const TypeAryKlassPtr *TypeAryKlassPtr::make(PTR ptr, const Type* elem, ciKlass* k, int offset) {
!   return (TypeAryKlassPtr*)(new TypeAryKlassPtr(ptr, elem, k, offset))->hashcons();
  }
  
! const TypeAryKlassPtr *TypeAryKlassPtr::make(PTR ptr, ciKlass* klass, int offset) {
    if (klass->is_obj_array_klass()) {
      // Element is an object array. Recursively call ourself.
      ciKlass* eklass = klass->as_obj_array_klass()->element_klass();
      const TypeKlassPtr *etype = TypeKlassPtr::make(eklass)->cast_to_exactness(false);
!     return TypeAryKlassPtr::make(ptr, etype, NULL, offset);
    } else if (klass->is_type_array_klass()) {
      // Element is an typeArray
      const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
!     return TypeAryKlassPtr::make(ptr, etype, klass, offset);
    } else {
      ShouldNotReachHere();
      return NULL;
    }
  }
  
! const TypeAryKlassPtr* TypeAryKlassPtr::make(ciKlass* klass) {
!   return TypeAryKlassPtr::make(Constant, klass, 0);
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeAryKlassPtr::eq(const Type *t) const {
    const TypeAryKlassPtr *p = t->is_aryklassptr();
    return
      _elem == p->_elem &&  // Check array
      TypeKlassPtr::eq(p);  // Check sub-parts
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
--- 5891,103 ---
          // below the centerline when the superclass is exact. We need
          // to do the same here.
          if (klass()->equals(ciEnv::current()->Object_klass())) {
            // that is, tp's array type is a subtype of my klass
            return TypeAryKlassPtr::make(ptr,
!                                        tp->elem(), tp->klass(), offset, tp->is_not_flat(), tp->is_not_null_free(), tp->null_free());
          }
        }
        // The other case cannot happen, since I cannot be a subtype of an array.
        // The meet falls down to Object class below centerline.
        if( ptr == Constant )
           ptr = NotNull;
!       return make(ptr, ciEnv::current()->Object_klass(), offset, false);
      default: typerr(t);
      }
    }
+   case InlineType: {
+     const TypeInlineType* tv = t->is_inlinetype();
+     if (above_centerline(ptr())) {
+       if (tv->inline_klass()->is_subtype_of(_klass)) {
+         return t;
+       } else {
+         return TypeInstPtr::NOTNULL;
+       }
+     } else {
+       PTR ptr = this->_ptr;
+       if (ptr == Constant) {
+         ptr = NotNull;
+       }
+       if (tv->inline_klass()->is_subtype_of(_klass)) {
+         return make(ptr, _klass, Offset(0), _flatten_array);
+       } else {
+         return make(ptr, ciEnv::current()->Object_klass(), Offset(0));
+       }
+     }
+   }
  
    } // End of switch
    return this;                  // Return the double constant
  }
  
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const Type    *TypeInstKlassPtr::xdual() const {
!   return new TypeInstKlassPtr(dual_ptr(), klass(), dual_offset(), flatten_array());
  }
  
! const TypeAryKlassPtr *TypeAryKlassPtr::make(PTR ptr, const Type* elem, ciKlass* k, Offset offset, bool not_flat, bool not_null_free, bool null_free) {
!   return (TypeAryKlassPtr*)(new TypeAryKlassPtr(ptr, elem, k, offset, not_flat, not_null_free, null_free))->hashcons();
  }
  
! const TypeAryKlassPtr *TypeAryKlassPtr::make(PTR ptr, ciKlass* klass, Offset offset, bool not_flat, bool not_null_free, bool null_free) {
    if (klass->is_obj_array_klass()) {
      // Element is an object array. Recursively call ourself.
      ciKlass* eklass = klass->as_obj_array_klass()->element_klass();
      const TypeKlassPtr *etype = TypeKlassPtr::make(eklass)->cast_to_exactness(false);
! 
+     // Even if MyValue is exact, [LMyValue is not exact due to [QMyValue <: [LMyValue.
+     if (etype->klass_is_exact() && etype->isa_instklassptr() && etype->is_instklassptr()->klass()->is_inlinetype() && !null_free) {
+       etype = TypeInstKlassPtr::make(NotNull, etype->is_instklassptr()->klass(), Offset(etype->is_instklassptr()->offset()), etype->is_instklassptr()->flatten_array());
+     }
+ 
+     const TypeAryKlassPtr* res = TypeAryKlassPtr::make(ptr, etype, NULL, offset, not_flat, not_null_free, null_free);
+     assert(res->klass() == klass, "");
+     return res;
    } else if (klass->is_type_array_klass()) {
      // Element is an typeArray
      const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
!     return TypeAryKlassPtr::make(ptr, etype, klass, offset, not_flat, not_null_free, null_free);
+   } else if (klass->is_flat_array_klass()) {
+     ciInlineKlass* vk = klass->as_array_klass()->element_klass()->as_inline_klass();
+     return TypeAryKlassPtr::make(ptr, TypeInlineType::make(vk), klass, offset, not_flat, not_null_free, null_free);
    } else {
      ShouldNotReachHere();
      return NULL;
    }
  }
  
! const TypeAryKlassPtr* TypeAryKlassPtr::make(ciKlass* k, PTR ptr, Offset offset) {
!   bool null_free = k->as_array_klass()->is_elem_null_free();
+   bool not_null_free = ptr == Constant ? !null_free : !k->is_flat_array_klass() && (k->is_type_array_klass() || !k->as_array_klass()->element_klass()->can_be_inline_klass(false));
+ 
+   bool not_flat = !UseFlatArray || not_null_free || (k->as_array_klass()->element_klass() != NULL &&
+                                                      k->as_array_klass()->element_klass()->is_inlinetype() &&
+                                                      !k->as_array_klass()->element_klass()->flatten_array());
+ 
+   return TypeAryKlassPtr::make(ptr, k, offset, not_flat, not_null_free, null_free);
  }
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeAryKlassPtr::eq(const Type *t) const {
    const TypeAryKlassPtr *p = t->is_aryklassptr();
    return
      _elem == p->_elem &&  // Check array
+     _not_flat == p->_not_flat &&
+     _not_null_free == p->_not_null_free &&
+     _null_free == p->_null_free &&
      TypeKlassPtr::eq(p);  // Check sub-parts
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.

*** 5440,21 ***
  //----------------------compute_klass------------------------------------------
  // Compute the defining klass for this class
  ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const {
    // Compute _klass based on element type.
    ciKlass* k_ary = NULL;
-   const TypeInstPtr *tinst;
    const TypeAryPtr *tary;
    const Type* el = elem();
    if (el->isa_narrowoop()) {
      el = el->make_ptr();
    }
  
    // Get element klass
!   if ((tinst = el->isa_instptr()) != NULL) {
!     // Compute array klass from element klass
!     k_ary = ciObjArrayKlass::make(tinst->klass());
    } else if ((tary = el->isa_aryptr()) != NULL) {
      // Compute array klass from element klass
      ciKlass* k_elem = tary->klass();
      // If element type is something like bottom[], k_elem will be null.
      if (k_elem != NULL)
--- 5998,26 ---
  //----------------------compute_klass------------------------------------------
  // Compute the defining klass for this class
  ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const {
    // Compute _klass based on element type.
    ciKlass* k_ary = NULL;
    const TypeAryPtr *tary;
    const Type* el = elem();
    if (el->isa_narrowoop()) {
      el = el->make_ptr();
    }
  
    // Get element klass
!   if (el->isa_instptr()) {
!     // Compute object array klass from element klass
!     bool null_free = el->is_inlinetypeptr() && el->isa_instptr()->ptr() != TypePtr::TopPTR && !el->isa_instptr()->maybe_null();
+     k_ary = ciArrayKlass::make(el->is_oopptr()->klass(), null_free);
+   } else if (el->isa_inlinetype()) {
+     // If element type is TypeInlineType::BOTTOM, inline_klass() will be null.
+     if (el->inline_klass() != NULL) {
+       k_ary = ciArrayKlass::make(el->inline_klass(), /* null_free */ true);
+     }
    } else if ((tary = el->isa_aryptr()) != NULL) {
      // Compute array klass from element klass
      ciKlass* k_elem = tary->klass();
      // If element type is something like bottom[], k_elem will be null.
      if (k_elem != NULL)

*** 5515,33 ***
      // Recomputing the underlying ciKlass for each request is
      // a bit less efficient than caching, but calls to
      // TypeAryPtr::OOPS->klass() are not common enough to matter.
      ((TypeAryPtr*)this)->_klass = k_ary;
      if (UseCompressedOops && k_ary != NULL && k_ary->is_obj_array_klass() &&
!         _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes()) {
        ((TypeAryPtr*)this)->_is_ptr_to_narrowoop = true;
      }
    }
    return k_ary;
  }
  
  
  //------------------------------add_offset-------------------------------------
  // Access internals of klass object
  const TypePtr *TypeAryKlassPtr::add_offset(intptr_t offset) const {
!   return make(_ptr, elem(), klass(), xadd_offset(offset));
  }
  
  const TypeKlassPtr *TypeAryKlassPtr::with_offset(intptr_t offset) const {
!   return make(_ptr, elem(), klass(), offset);
  }
  
  //------------------------------cast_to_ptr_type-------------------------------
  const TypePtr* TypeAryKlassPtr::cast_to_ptr_type(PTR ptr) const {
    assert(_base == AryKlassPtr, "subclass must override cast_to_ptr_type");
    if (ptr == _ptr) return this;
!   return make(ptr, elem(), _klass, _offset);
  }
  
  bool TypeAryKlassPtr::must_be_exact() const {
    if (_elem == Type::BOTTOM) return false;
    if (_elem == Type::TOP   ) return false;
--- 6078,33 ---
      // Recomputing the underlying ciKlass for each request is
      // a bit less efficient than caching, but calls to
      // TypeAryPtr::OOPS->klass() are not common enough to matter.
      ((TypeAryPtr*)this)->_klass = k_ary;
      if (UseCompressedOops && k_ary != NULL && k_ary->is_obj_array_klass() &&
!         offset() != 0 && offset() != arrayOopDesc::length_offset_in_bytes()) {
        ((TypeAryPtr*)this)->_is_ptr_to_narrowoop = true;
      }
    }
    return k_ary;
  }
  
  
  //------------------------------add_offset-------------------------------------
  // Access internals of klass object
  const TypePtr *TypeAryKlassPtr::add_offset(intptr_t offset) const {
!   return make(_ptr, elem(), klass(), xadd_offset(offset), is_not_flat(), is_not_null_free(), _null_free);
  }
  
  const TypeKlassPtr *TypeAryKlassPtr::with_offset(intptr_t offset) const {
!   return make(_ptr, elem(), klass(), Offset(offset), is_not_flat(), is_not_null_free(), _null_free);
  }
  
  //------------------------------cast_to_ptr_type-------------------------------
  const TypePtr* TypeAryKlassPtr::cast_to_ptr_type(PTR ptr) const {
    assert(_base == AryKlassPtr, "subclass must override cast_to_ptr_type");
    if (ptr == _ptr) return this;
!   return make(ptr, elem(), _klass, _offset, is_not_flat(), is_not_null_free(), _null_free);
  }
  
  bool TypeAryKlassPtr::must_be_exact() const {
    if (_elem == Type::BOTTOM) return false;
    if (_elem == Type::TOP   ) return false;

*** 5551,28 ***
  }
  
  
  //-----------------------------cast_to_exactness-------------------------------
  const TypeKlassPtr *TypeAryKlassPtr::cast_to_exactness(bool klass_is_exact) const {
!   if (must_be_exact()) return this;  // cannot clear xk
    ciKlass* k = _klass;
    const Type* elem = this->elem();
    if (elem->isa_klassptr() && !klass_is_exact) {
      elem = elem->is_klassptr()->cast_to_exactness(klass_is_exact);
    }
!   return make(klass_is_exact ? Constant : NotNull, elem, k, _offset);
  }
  
  
  //-----------------------------as_instance_type--------------------------------
  // Corresponding type for an instance of the given class.
  // It will be exact if and only if the klass type is exact.
  const TypeOopPtr* TypeAryKlassPtr::as_instance_type() const {
    ciKlass* k = klass();
    bool    xk = klass_is_exact();
    const Type* el = elem()->isa_klassptr() ? elem()->is_klassptr()->as_instance_type()->is_oopptr()->cast_to_exactness(false) : elem();
!   return TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(el, TypeInt::POS), k, xk, 0);
  }
  
  
  //------------------------------xmeet------------------------------------------
  // Compute the MEET of two types, return a new Type object.
--- 6114,42 ---
  }
  
  
  //-----------------------------cast_to_exactness-------------------------------
  const TypeKlassPtr *TypeAryKlassPtr::cast_to_exactness(bool klass_is_exact) const {
!   if (must_be_exact() && !klass_is_exact) return this;  // cannot clear xk
    ciKlass* k = _klass;
    const Type* elem = this->elem();
    if (elem->isa_klassptr() && !klass_is_exact) {
      elem = elem->is_klassptr()->cast_to_exactness(klass_is_exact);
    }
!   bool not_flat = is_not_flat();
+   bool not_null_free = is_not_null_free();
+   if (klass() != NULL && klass()->is_obj_array_klass() && klass_is_exact) {
+     // An object array can't be flat or null-free if the klass is exact
+     not_flat = true;
+     not_null_free = true;
+   }
+   return make(klass_is_exact ? Constant : NotNull, elem, k, _offset, not_flat, not_null_free, _null_free);
  }
  
  
  //-----------------------------as_instance_type--------------------------------
  // Corresponding type for an instance of the given class.
  // It will be exact if and only if the klass type is exact.
  const TypeOopPtr* TypeAryKlassPtr::as_instance_type() const {
    ciKlass* k = klass();
+   assert(k != NULL, "klass should not be NULL");
    bool    xk = klass_is_exact();
    const Type* el = elem()->isa_klassptr() ? elem()->is_klassptr()->as_instance_type()->is_oopptr()->cast_to_exactness(false) : elem();
!   bool null_free = _null_free;
+   if (null_free && el->isa_ptr()) {
+     el = el->is_ptr()->join_speculative(TypePtr::NOTNULL);
+   }
+   bool not_flat = is_not_flat();
+   bool not_null_free = is_not_null_free();
+   return TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(el, TypeInt::POS, false, not_flat, not_null_free), k, xk, Offset(0));
  }
  
  
  //------------------------------xmeet------------------------------------------
  // Compute the MEET of two types, return a new Type object.

*** 5602,19 ***
      typerr(t);
  
    case AnyPtr: {                // Meeting to AnyPtrs
      // Found an AnyPtr type vs self-KlassPtr type
      const TypePtr *tp = t->is_ptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      switch (tp->ptr()) {
      case TopPTR:
        return this;
      case Null:
        if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
      case AnyNull:
!       return make( ptr, _elem, klass(), offset );
      case BotPTR:
      case NotNull:
        return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
      default: typerr(t);
      }
--- 6179,19 ---
      typerr(t);
  
    case AnyPtr: {                // Meeting to AnyPtrs
      // Found an AnyPtr type vs self-KlassPtr type
      const TypePtr *tp = t->is_ptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
      switch (tp->ptr()) {
      case TopPTR:
        return this;
      case Null:
        if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
      case AnyNull:
!       return make(ptr, _elem, klass(), offset, is_not_flat(), is_not_null_free(), _null_free);
      case BotPTR:
      case NotNull:
        return TypePtr::make(AnyPtr, ptr, offset, tp->speculative(), tp->inline_depth());
      default: typerr(t);
      }

*** 5643,37 ***
    //             A-bot         }
    //
  
    case AryKlassPtr: {  // Meet two KlassPtr types
      const TypeAryKlassPtr *tap = t->is_aryklassptr();
!     int off = meet_offset(tap->offset());
!     const Type* elem = _elem->meet(tap->_elem);
- 
      PTR ptr = meet_ptr(tap->ptr());
      ciKlass* res_klass = NULL;
      bool res_xk = false;
!     meet_aryptr(ptr, elem, this->klass(), tap->klass(), this->klass_is_exact(), tap->klass_is_exact(), this->ptr(), tap->ptr(), res_klass, res_xk);
      assert(res_xk == (ptr == Constant), "");
!     return make(ptr, elem, res_klass, off);
    } // End of case KlassPtr
    case InstKlassPtr: {
      const TypeInstKlassPtr *tp = t->is_instklassptr();
!     int offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
  
      switch (ptr) {
      case TopPTR:
      case AnyNull:                // Fall 'down' to dual of object klass
        // For instances when a subclass meets a superclass we fall
        // below the centerline when the superclass is exact. We need to
        // do the same here.
        if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
!         return TypeAryKlassPtr::make(ptr, _elem, _klass, offset);
        } else {
          // cannot subclass, so the meet has to fall badly below the centerline
          ptr = NotNull;
!         return TypeInstKlassPtr::make(ptr, ciEnv::current()->Object_klass(), offset);
        }
      case Constant:
      case NotNull:
      case BotPTR:                // Fall down to object klass
        // LCA is object_klass, but if we subclass from the top we can do better
--- 6220,52 ---
    //             A-bot         }
    //
  
    case AryKlassPtr: {  // Meet two KlassPtr types
      const TypeAryKlassPtr *tap = t->is_aryklassptr();
!     Offset off = meet_offset(tap->offset());
!     const Type* res_elem = NULL;
      PTR ptr = meet_ptr(tap->ptr());
      ciKlass* res_klass = NULL;
      bool res_xk = false;
!     bool res_not_flat = false;
+     bool res_not_null_free = false;
+     MeetResult res = meet_aryptr(ptr, _elem, tap->_elem, this->klass(), tap->klass(),
+                                  this->klass_is_exact(), tap->klass_is_exact(),
+                                  this->ptr(), tap->ptr(), this->is_not_flat(), tap->is_not_flat(),
+                                  this->is_not_null_free(), tap->is_not_null_free(),
+                                  res_elem, res_klass, res_xk, res_not_flat, res_not_null_free);
      assert(res_xk == (ptr == Constant), "");
!     bool null_free = meet_null_free(tap->_null_free);
+     if (res == NOT_SUBTYPE) {
+       null_free = false;
+     } else if (res == SUBTYPE) {
+       if (above_centerline(tap->ptr()) && !above_centerline(this->ptr())) {
+         null_free = _null_free;
+       } else if (above_centerline(this->ptr()) && !above_centerline(tap->ptr())) {
+         null_free = tap->_null_free;
+       }
+     }
+     return make(ptr, res_elem, res_klass, off, res_not_flat, res_not_null_free, null_free);
    } // End of case KlassPtr
    case InstKlassPtr: {
      const TypeInstKlassPtr *tp = t->is_instklassptr();
!     Offset offset = meet_offset(tp->offset());
      PTR ptr = meet_ptr(tp->ptr());
  
      switch (ptr) {
      case TopPTR:
      case AnyNull:                // Fall 'down' to dual of object klass
        // For instances when a subclass meets a superclass we fall
        // below the centerline when the superclass is exact. We need to
        // do the same here.
        if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
!         return TypeAryKlassPtr::make(ptr, _elem, _klass, offset, is_not_flat(), is_not_null_free(), _null_free);
        } else {
          // cannot subclass, so the meet has to fall badly below the centerline
          ptr = NotNull;
!         return TypeInstKlassPtr::make(ptr, ciEnv::current()->Object_klass(), offset, false);
        }
      case Constant:
      case NotNull:
      case BotPTR:                // Fall down to object klass
        // LCA is object_klass, but if we subclass from the top we can do better

*** 5683,42 ***
          // For instances when a subclass meets a superclass we fall
          // below the centerline when the superclass is exact. We need
          // to do the same here.
          if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
            // that is, my array type is a subtype of 'tp' klass
!           return make(ptr, _elem, _klass, offset);
          }
        }
        // The other case cannot happen, since t cannot be a subtype of an array.
        // The meet falls down to Object class below centerline.
        if (ptr == Constant)
           ptr = NotNull;
!       return TypeInstKlassPtr::make(ptr, ciEnv::current()->Object_klass(), offset);
      default: typerr(t);
      }
    }
  
    } // End of switch
    return this;                  // Return the double constant
  }
  
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const Type    *TypeAryKlassPtr::xdual() const {
!   return new TypeAryKlassPtr(dual_ptr(), elem()->dual(), klass(), dual_offset());
  }
  
  //------------------------------get_con----------------------------------------
  ciKlass* TypeAryKlassPtr::klass() const {
!   if (_klass != NULL) {
      return _klass;
    }
    ciKlass* k = NULL;
!   if (elem()->isa_klassptr()) {
!     k = elem()->is_klassptr()->klass();
!     if (k != NULL) {
!       k = ciObjArrayKlass::make(k);
        ((TypeAryKlassPtr*)this)->_klass = k;
      }
    } else if ((elem()->base() == Type::Top) ||
               (elem()->base() == Type::Bottom)) {
    } else {
--- 6275,68 ---
          // For instances when a subclass meets a superclass we fall
          // below the centerline when the superclass is exact. We need
          // to do the same here.
          if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
            // that is, my array type is a subtype of 'tp' klass
!           return make(ptr, _elem, _klass, offset, is_not_flat(), is_not_null_free(), _null_free);
          }
        }
        // The other case cannot happen, since t cannot be a subtype of an array.
        // The meet falls down to Object class below centerline.
        if (ptr == Constant)
           ptr = NotNull;
!       return TypeInstKlassPtr::make(ptr, ciEnv::current()->Object_klass(), offset, false);
      default: typerr(t);
      }
    }
+   case InlineType: {
+     const TypeInlineType* tv = t->is_inlinetype();
+     if (above_centerline(ptr())) {
+       return TypeInstKlassPtr::BOTTOM;
+     } else {
+       PTR ptr = this->_ptr;
+       if (ptr == Constant) {
+         ptr = NotNull;
+       }
+       return TypeInstKlassPtr::make(ptr, ciEnv::current()->Object_klass(), Offset(0));
+     }
+   }
  
    } // End of switch
    return this;                  // Return the double constant
  }
  
  //------------------------------xdual------------------------------------------
  // Dual: compute field-by-field dual
  const Type    *TypeAryKlassPtr::xdual() const {
!   return new TypeAryKlassPtr(dual_ptr(), elem()->dual(), klass(), dual_offset(), !is_not_flat(), !is_not_null_free(), dual_null_free());
  }
  
  //------------------------------get_con----------------------------------------
  ciKlass* TypeAryKlassPtr::klass() const {
!     if (_klass != NULL) {
      return _klass;
    }
    ciKlass* k = NULL;
!   const Type* el = elem();
!   if (el->isa_instklassptr()) {
!     // Compute object array klass from element klass
!     bool null_free = el->is_instklassptr()->klass()->is_inlinetype() && el->isa_instklassptr()->ptr() != TypePtr::TopPTR && (_null_free != 0);
+     k = ciArrayKlass::make(el->is_klassptr()->klass(), null_free);
+     ((TypeAryKlassPtr*)this)->_klass = k;
+   } else if (el->isa_inlinetype()) {
+     // If element type is TypeInlineType::BOTTOM, inline_klass() will be null.
+     if (el->inline_klass() != NULL) {
+       k = ciArrayKlass::make(el->inline_klass(), /* null_free */ true);
+       ((TypeAryKlassPtr*)this)->_klass = k;
+     }
+   } else if (el->isa_aryklassptr() != NULL) {
+     // Compute array klass from element klass
+     ciKlass* k_elem = el->is_aryklassptr()->klass();
+     // If element type is something like bottom[], k_elem will be null.
+     if (k_elem != NULL) {
+       k = ciObjArrayKlass::make(k_elem);
        ((TypeAryKlassPtr*)this)->_klass = k;
      }
    } else if ((elem()->base() == Type::Top) ||
               (elem()->base() == Type::Bottom)) {
    } else {

*** 5735,10 ***
--- 6353,14 ---
    case Constant:
      st->print("precise ");
    case NotNull:
      {
        st->print("[");
+       if (_elem->isa_inlinetype()) {
+         const char *name = _elem->is_inlinetype()->inline_klass()->name()->as_utf8();
+         st->print("precise %s: " INTPTR_FORMAT " ", name, p2i(klass()));
+       }
        _elem->dump2(d, depth, st);
        st->print(": ");
      }
    case BotPTR:
      if( !WizardMode && !Verbose && _ptr != Constant ) break;

*** 5748,17 ***
      if( _ptr == Constant ) st->print(":exact");
      break;
    default:
      break;
    }
! 
!   if( _offset ) {               // Dump offset, if any
!     if( _offset == OffsetBot )      { st->print("+any"); }
!     else if( _offset == OffsetTop ) { st->print("+unknown"); }
-     else                            { st->print("+%d", _offset); }
    }
  
    st->print(" *");
  }
  #endif
  
  const Type* TypeAryKlassPtr::base_element_type(int& dims) const {
--- 6370,18 ---
      if( _ptr == Constant ) st->print(":exact");
      break;
    default:
      break;
    }
!   if (Verbose) {
!     if (_not_flat) st->print(":not flat");
!     if (_not_null_free) st->print(":not null free");
!     if (_null_free != 0) st->print(":null free(%d)", _null_free);
    }
  
+   _offset.dump2(st);
+ 
    st->print(" *");
  }
  #endif
  
  const Type* TypeAryKlassPtr::base_element_type(int& dims) const {

*** 5773,28 ***
  
  //=============================================================================
  // Convenience common pre-built types.
  
  //------------------------------make-------------------------------------------
! const TypeFunc *TypeFunc::make( const TypeTuple *domain, const TypeTuple *range ) {
!   return (TypeFunc*)(new TypeFunc(domain,range))->hashcons();
  }
  
  //------------------------------make-------------------------------------------
! const TypeFunc *TypeFunc::make(ciMethod* method) {
    Compile* C = Compile::current();
!   const TypeFunc* tf = C->last_tf(method); // check cache
!   if (tf != NULL)  return tf;  // The hit rate here is almost 50%.
!   const TypeTuple *domain;
!   if (method->is_static()) {
!     domain = TypeTuple::make_domain(NULL, method->signature());
!   } else {
!     domain = TypeTuple::make_domain(method->holder(), method->signature());
    }
-   const TypeTuple *range  = TypeTuple::make_range(method->signature());
-   tf = TypeFunc::make(domain, range);
-   C->set_last_tf(method, tf);  // fill cache
    return tf;
  }
  
  //------------------------------meet-------------------------------------------
  // Compute the MEET of two types.  It returns a new Type object.
--- 6396,50 ---
  
  //=============================================================================
  // Convenience common pre-built types.
  
  //------------------------------make-------------------------------------------
! const TypeFunc *TypeFunc::make(const TypeTuple *domain_sig, const TypeTuple* domain_cc,
!                                const TypeTuple *range_sig, const TypeTuple *range_cc) {
+   return (TypeFunc*)(new TypeFunc(domain_sig, domain_cc, range_sig, range_cc))->hashcons();
+ }
+ 
+ const TypeFunc *TypeFunc::make(const TypeTuple *domain, const TypeTuple *range) {
+   return make(domain, domain, range, range);
+ }
+ 
+ //------------------------------osr_domain-----------------------------
+ const TypeTuple* osr_domain() {
+   const Type **fields = TypeTuple::fields(2);
+   fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM;  // address of osr buffer
+   return TypeTuple::make(TypeFunc::Parms+1, fields);
  }
  
  //------------------------------make-------------------------------------------
! const TypeFunc* TypeFunc::make(ciMethod* method, bool is_osr_compilation) {
    Compile* C = Compile::current();
!   const TypeFunc* tf = NULL;
!   if (!is_osr_compilation) {
!     tf = C->last_tf(method); // check cache
!     if (tf != NULL)  return tf;  // The hit rate here is almost 50%.
!   }
!   // Inline types are not passed/returned by reference, instead each field of
!   // the inline type is passed/returned as an argument. We maintain two views of
+   // the argument/return list here: one based on the signature (with an inline
+   // type argument/return as a single slot), one based on the actual calling
+   // convention (with an inline type argument/return as a list of its fields).
+   bool has_scalar_args = method->has_scalarized_args() && !is_osr_compilation;
+   const TypeTuple* domain_sig = is_osr_compilation ? osr_domain() : TypeTuple::make_domain(method, false);
+   const TypeTuple* domain_cc = has_scalar_args ? TypeTuple::make_domain(method, true) : domain_sig;
+   ciSignature* sig = method->signature();
+   bool has_scalar_ret = sig->returns_null_free_inline_type() && sig->return_type()->as_inline_klass()->can_be_returned_as_fields();
+   const TypeTuple* range_sig = TypeTuple::make_range(sig, false);
+   const TypeTuple* range_cc = has_scalar_ret ? TypeTuple::make_range(sig, true) : range_sig;
+   tf = TypeFunc::make(domain_sig, domain_cc, range_sig, range_cc);
+   if (!is_osr_compilation) {
+     C->set_last_tf(method, tf);  // fill cache
    }
    return tf;
  }
  
  //------------------------------meet-------------------------------------------
  // Compute the MEET of two types.  It returns a new Type object.

*** 5825,46 ***
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeFunc::eq( const Type *t ) const {
    const TypeFunc *a = (const TypeFunc*)t;
!   return _domain == a->_domain &&
!     _range == a->_range;
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeFunc::hash(void) const {
!   return (intptr_t)_domain + (intptr_t)_range;
  }
  
  //------------------------------dump2------------------------------------------
  // Dump Function Type
  #ifndef PRODUCT
  void TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const {
!   if( _range->cnt() <= Parms )
      st->print("void");
    else {
      uint i;
!     for (i = Parms; i < _range->cnt()-1; i++) {
!       _range->field_at(i)->dump2(d,depth,st);
        st->print("/");
      }
!     _range->field_at(i)->dump2(d,depth,st);
    }
    st->print(" ");
    st->print("( ");
    if( !depth || d[this] ) {     // Check for recursive dump
      st->print("...)");
      return;
    }
    d.Insert((void*)this,(void*)this);    // Stop recursion
!   if (Parms < _domain->cnt())
!     _domain->field_at(Parms)->dump2(d,depth-1,st);
!   for (uint i = Parms+1; i < _domain->cnt(); i++) {
      st->print(", ");
!     _domain->field_at(i)->dump2(d,depth-1,st);
    }
    st->print(" )");
  }
  #endif
  
--- 6470,48 ---
  
  //------------------------------eq---------------------------------------------
  // Structural equality check for Type representations
  bool TypeFunc::eq( const Type *t ) const {
    const TypeFunc *a = (const TypeFunc*)t;
!   return _domain_sig == a->_domain_sig &&
!     _domain_cc == a->_domain_cc &&
+     _range_sig == a->_range_sig &&
+     _range_cc == a->_range_cc;
  }
  
  //------------------------------hash-------------------------------------------
  // Type-specific hashing function.
  int TypeFunc::hash(void) const {
!   return (intptr_t)_domain_sig + (intptr_t)_domain_cc + (intptr_t)_range_sig + (intptr_t)_range_cc;
  }
  
  //------------------------------dump2------------------------------------------
  // Dump Function Type
  #ifndef PRODUCT
  void TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const {
!   if( _range_sig->cnt() <= Parms )
      st->print("void");
    else {
      uint i;
!     for (i = Parms; i < _range_sig->cnt()-1; i++) {
!       _range_sig->field_at(i)->dump2(d,depth,st);
        st->print("/");
      }
!     _range_sig->field_at(i)->dump2(d,depth,st);
    }
    st->print(" ");
    st->print("( ");
    if( !depth || d[this] ) {     // Check for recursive dump
      st->print("...)");
      return;
    }
    d.Insert((void*)this,(void*)this);    // Stop recursion
!   if (Parms < _domain_sig->cnt())
!     _domain_sig->field_at(Parms)->dump2(d,depth-1,st);
!   for (uint i = Parms+1; i < _domain_sig->cnt(); i++) {
      st->print(", ");
!     _domain_sig->field_at(i)->dump2(d,depth-1,st);
    }
    st->print(" )");
  }
  #endif
  

*** 5880,10 ***
    return false;                 // Never empty
  }
  
  
  BasicType TypeFunc::return_type() const{
!   if (range()->cnt() == TypeFunc::Parms) {
      return T_VOID;
    }
!   return range()->field_at(TypeFunc::Parms)->basic_type();
  }
--- 6527,10 ---
    return false;                 // Never empty
  }
  
  
  BasicType TypeFunc::return_type() const{
!   if (range_sig()->cnt() == TypeFunc::Parms) {
      return T_VOID;
    }
!   return range_sig()->field_at(TypeFunc::Parms)->basic_type();
  }
< prev index next >