< prev index next >
src/hotspot/share/opto/type.cpp
Print this page
*** 1932,1944 ****
static void collect_value_fields(ciValueKlass* 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());
- if (bt == T_VALUETYPE) {
- ft = ft->isa_valuetypeptr()->cast_to_ptr_type(TypePtr::BotPTR);
- }
field_array[pos++] = ft;
if (bt == T_LONG || bt == T_DOUBLE) {
field_array[pos++] = Type::HALF;
}
}
--- 1932,1941 ----
*** 1989,1999 ****
uint pos = TypeFunc::Parms;
field_array[pos] = TypePtr::BOTTOM;
pos++;
collect_value_fields(vk, field_array, pos);
} else {
! field_array[TypeFunc::Parms] = get_const_type(return_type);
}
break;
case T_VOID:
break;
default:
--- 1986,1997 ----
uint pos = TypeFunc::Parms;
field_array[pos] = TypePtr::BOTTOM;
pos++;
collect_value_fields(vk, field_array, pos);
} else {
! // Value type returns cannot be NULL
! field_array[TypeFunc::Parms] = get_const_type(return_type)->join_speculative(TypePtr::NOTNULL);
}
break;
case T_VOID:
break;
default:
*** 2069,2079 ****
assert(type->is_valuetype(), "inconsistent type");
if (vt_fields_as_args && !type->is__Value()) {
ciValueKlass* vk = (ciValueKlass*)type;
collect_value_fields(vk, field_array, pos);
} else {
! field_array[pos++] = get_const_type(type);
}
break;
}
default:
ShouldNotReachHere();
--- 2067,2078 ----
assert(type->is_valuetype(), "inconsistent type");
if (vt_fields_as_args && !type->is__Value()) {
ciValueKlass* vk = (ciValueKlass*)type;
collect_value_fields(vk, field_array, pos);
} else {
! // Value types arguments cannot be NULL
! field_array[pos++] = get_const_type(type)->join_speculative(TypePtr::NOTNULL);
}
break;
}
default:
ShouldNotReachHere();
*** 2214,2223 ****
--- 2213,2226 ----
return size;
}
//------------------------------make-------------------------------------------
const TypeAry* TypeAry::make(const Type* elem, const TypeInt* size, bool stable) {
+ if (elem->isa_valuetypeptr()) {
+ // Value type array elements cannot be NULL
+ elem = elem->join_speculative(TypePtr::NOTNULL)->is_oopptr();
+ }
if (UseCompressedOops && elem->isa_oopptr()) {
elem = elem->make_narrowoop();
}
size = normalize_array_size(size);
return (TypeAry*)(new TypeAry(elem,size,stable))->hashcons();
*** 3365,3375 ****
//--------------------------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_valuetype()) {
! return TypeValueTypePtr::make(TypePtr::NotNull, klass->as_value_klass());
} else 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
--- 3368,3378 ----
//--------------------------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_valuetype()) {
! return TypeValueTypePtr::make(TypePtr::BotPTR, klass->as_value_klass());
} else 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
*** 3415,3436 ****
// 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_value_array_klass()) {
ciValueKlass* vk = klass->as_array_klass()->element_klass()->as_value_klass();
! const Type* etype = NULL;
! bool xk = false;
! if (vk->flatten_array()) {
! etype = TypeValueType::make(vk);
! xk = true;
! } else {
! const TypeOopPtr* etype_oop = TypeOopPtr::make_from_klass_common(vk, false, try_for_exact);
! xk = etype_oop->klass_is_exact();
! etype = etype_oop;
! }
! const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
! const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, Offset(0));
return arr;
} else {
ShouldNotReachHere();
return NULL;
}
--- 3418,3429 ----
// 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_value_array_klass()) {
ciValueKlass* vk = klass->as_array_klass()->element_klass()->as_value_klass();
! const TypeAry* arr0 = TypeAry::make(TypeValueType::make(vk), TypeInt::POS);
! const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, Offset(0));
return arr;
} else {
ShouldNotReachHere();
return NULL;
}
*** 4782,4809 ****
//=============================================================================
const TypeValueTypePtr* TypeValueTypePtr::NOTNULL;
//------------------------------make-------------------------------------------
! const TypeValueTypePtr* TypeValueTypePtr::make(const TypeValueType* vt, PTR ptr, ciObject* o, Offset offset, int instance_id, const TypePtr* speculative, int inline_depth, bool narrow) {
! return (TypeValueTypePtr*)(new TypeValueTypePtr(vt, ptr, o, offset, instance_id, speculative, inline_depth))->hashcons();
}
const TypePtr* TypeValueTypePtr::add_offset(intptr_t offset) const {
! return make(_vt, _ptr, _const_oop, Offset(offset), _instance_id, _speculative, _inline_depth);
}
//------------------------------cast_to_ptr_type-------------------------------
const Type* TypeValueTypePtr::cast_to_ptr_type(PTR ptr) const {
if (ptr == _ptr) return this;
! return make(_vt, ptr, _const_oop, _offset, _instance_id, _speculative, _inline_depth);
}
//-----------------------------cast_to_instance_id----------------------------
const TypeOopPtr* TypeValueTypePtr::cast_to_instance_id(int instance_id) const {
if (instance_id == _instance_id) return this;
! return make(_vt, _ptr, _const_oop, _offset, instance_id, _speculative, _inline_depth);
}
//------------------------------meet-------------------------------------------
// Compute the MEET of two types. It returns a new Type object.
const Type* TypeValueTypePtr::xmeet_helper(const Type* t) const {
--- 4775,4802 ----
//=============================================================================
const TypeValueTypePtr* TypeValueTypePtr::NOTNULL;
//------------------------------make-------------------------------------------
! const TypeValueTypePtr* TypeValueTypePtr::make(PTR ptr, ciValueKlass* vk, ciObject* o, Offset offset, int instance_id, const TypePtr* speculative, int inline_depth, bool narrow) {
! return (TypeValueTypePtr*)(new TypeValueTypePtr(ptr, vk, o, offset, instance_id, speculative, inline_depth))->hashcons();
}
const TypePtr* TypeValueTypePtr::add_offset(intptr_t offset) const {
! return make(_ptr, value_klass(), _const_oop, Offset(offset), _instance_id, _speculative, _inline_depth);
}
//------------------------------cast_to_ptr_type-------------------------------
const Type* TypeValueTypePtr::cast_to_ptr_type(PTR ptr) const {
if (ptr == _ptr) return this;
! return make(ptr, value_klass(), _const_oop, _offset, _instance_id, _speculative, _inline_depth);
}
//-----------------------------cast_to_instance_id----------------------------
const TypeOopPtr* TypeValueTypePtr::cast_to_instance_id(int instance_id) const {
if (instance_id == _instance_id) return this;
! return make(_ptr, value_klass(), _const_oop, _offset, instance_id, _speculative, _inline_depth);
}
//------------------------------meet-------------------------------------------
// Compute the MEET of two types. It returns a new Type object.
const Type* TypeValueTypePtr::xmeet_helper(const Type* t) const {
*** 4846,4856 ****
const TypePtr* speculative = xmeet_speculative(tp);
int depth = meet_inline_depth(tp->inline_depth());
switch (tp->ptr()) {
case TopPTR:
case AnyNull: {
! return make(_vt, ptr, NULL, offset, instance_id, speculative, depth);
}
case NotNull:
case BotPTR: {
return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);
}
--- 4839,4849 ----
const TypePtr* speculative = xmeet_speculative(tp);
int depth = meet_inline_depth(tp->inline_depth());
switch (tp->ptr()) {
case TopPTR:
case AnyNull: {
! return make(ptr, value_klass(), NULL, offset, instance_id, speculative, depth);
}
case NotNull:
case BotPTR: {
return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);
}
*** 4870,4880 ****
case Null:
if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth);
// else fall through to AnyNull
case TopPTR:
case AnyNull: {
! return make(_vt, ptr, NULL, offset, instance_id, speculative, depth);
}
case NotNull:
case BotPTR:
return TypePtr::make(AnyPtr, ptr, offset, speculative, depth);
default: typerr(t);
--- 4863,4873 ----
case Null:
if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset, speculative, depth);
// else fall through to AnyNull
case TopPTR:
case AnyNull: {
! return make(ptr, value_klass(), NULL, offset, instance_id, speculative, depth);
}
case NotNull:
case BotPTR:
return TypePtr::make(AnyPtr, ptr, offset, speculative, depth);
default: typerr(t);
*** 4891,4914 ****
int depth = meet_inline_depth(tp->inline_depth());
// Compute constant oop
ciObject* o = NULL;
ciObject* this_oop = const_oop();
ciObject* tp_oop = tp->const_oop();
! const TypeValueType* vt = NULL;
! if (_vt != tp->_vt) {
assert(is__Value() || tp->is__Value(), "impossible meet");
if (above_centerline(ptr)) {
! vt = is__Value() ? tp->_vt : _vt;
} else if (above_centerline(this->_ptr) && !above_centerline(tp->_ptr)) {
! vt = tp->_vt;
} else if (above_centerline(tp->_ptr) && !above_centerline(this->_ptr)) {
! vt = _vt;
} else {
! vt = is__Value() ? _vt : tp->_vt;
}
} else {
! vt = _vt;
}
if (ptr == Constant) {
if (this_oop != NULL && tp_oop != NULL &&
this_oop->equals(tp_oop) ) {
o = this_oop;
--- 4884,4907 ----
int depth = meet_inline_depth(tp->inline_depth());
// Compute constant oop
ciObject* o = NULL;
ciObject* this_oop = const_oop();
ciObject* tp_oop = tp->const_oop();
! ciKlass* klass = NULL;
! if (_klass != tp->_klass) {
assert(is__Value() || tp->is__Value(), "impossible meet");
if (above_centerline(ptr)) {
! klass = is__Value() ? tp->_klass : _klass;
} else if (above_centerline(this->_ptr) && !above_centerline(tp->_ptr)) {
! klass = tp->_klass;
} else if (above_centerline(tp->_ptr) && !above_centerline(this->_ptr)) {
! klass = _klass;
} else {
! klass = is__Value() ? _klass : tp->_klass;
}
} else {
! klass = _klass;
}
if (ptr == Constant) {
if (this_oop != NULL && tp_oop != NULL &&
this_oop->equals(tp_oop) ) {
o = this_oop;
*** 4918,4948 ****
o = this_oop;
} else {
ptr = NotNull;
}
}
! return make(vt, ptr, o, offset, instance_id, speculative, depth);
}
}
}
// Dual: compute field-by-field dual
const Type* TypeValueTypePtr::xdual() const {
! return new TypeValueTypePtr(_vt, dual_ptr(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
}
//------------------------------eq---------------------------------------------
// Structural equality check for Type representations
bool TypeValueTypePtr::eq(const Type* t) const {
const TypeValueTypePtr* p = t->is_valuetypeptr();
! return _vt->eq(p->value_type()) && TypeOopPtr::eq(p);
}
//------------------------------hash-------------------------------------------
// Type-specific hashing function.
int TypeValueTypePtr::hash(void) const {
! return java_add(_vt->hash(), TypeOopPtr::hash());
}
//------------------------------is__Value--------------------------------------
bool TypeValueTypePtr::is__Value() const {
return klass()->equals(TypeKlassPtr::VALUE->klass());
--- 4911,4941 ----
o = this_oop;
} else {
ptr = NotNull;
}
}
! return make(ptr, klass->as_value_klass(), o, offset, instance_id, speculative, depth);
}
}
}
// Dual: compute field-by-field dual
const Type* TypeValueTypePtr::xdual() const {
! return new TypeValueTypePtr(dual_ptr(), value_klass(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
}
//------------------------------eq---------------------------------------------
// Structural equality check for Type representations
bool TypeValueTypePtr::eq(const Type* t) const {
const TypeValueTypePtr* p = t->is_valuetypeptr();
! return klass()->equals(p->klass()) && TypeOopPtr::eq(p);
}
//------------------------------hash-------------------------------------------
// Type-specific hashing function.
int TypeValueTypePtr::hash(void) const {
! return java_add(klass()->hash(), TypeOopPtr::hash());
}
//------------------------------is__Value--------------------------------------
bool TypeValueTypePtr::is__Value() const {
return klass()->equals(TypeKlassPtr::VALUE->klass());
< prev index next >