Skip to content
Permalink
Browse files
8266550: C2: mirror TypeOopPtr/TypeInstPtr/TypeAryPtr with TypeKlassP…
…tr/TypeInstKlassPtr/TypeAryKlassPtr

Reviewed-by: vlivanov, thartmann
  • Loading branch information
rwestrel committed Sep 14, 2021
1 parent a143372 commit 1d2458db34ed6acdd20bb8c165b7619cdbc32f47
@@ -88,14 +88,14 @@ ArrayKlass::ArrayKlass(Symbol* name, KlassID id) :
_dimension(1),
_higher_dimension(NULL),
_lower_dimension(NULL) {
// Arrays don't add any new methods, so their vtable is the same size as
// the vtable of klass Object.
set_vtable_length(Universe::base_vtable_size());
set_name(name);
set_super(Universe::is_bootstrapping() ? NULL : vmClasses::Object_klass());
set_layout_helper(Klass::_lh_neutral_value);
set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5)
JFR_ONLY(INIT_ID(this);)
// Arrays don't add any new methods, so their vtable is the same size as
// the vtable of klass Object.
set_vtable_length(Universe::base_vtable_size());
set_name(name);
set_super(Universe::is_bootstrapping() ? NULL : vmClasses::Object_klass());
set_layout_helper(Klass::_lh_neutral_value);
set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5)
JFR_ONLY(INIT_ID(this);)
}


@@ -378,6 +378,8 @@ static void format_helper( PhaseRegAlloc *regalloc, outputStream* st, Node *n, c
st->print(" %s%d]=#Ptr" INTPTR_FORMAT,msg,i,p2i(t->isa_oopptr()->const_oop()));
break;
case Type::KlassPtr:
case Type::AryKlassPtr:
case Type::InstKlassPtr:
st->print(" %s%d]=#Ptr" INTPTR_FORMAT,msg,i,p2i(t->make_ptr()->isa_klassptr()->klass()));
break;
case Type::MetadataPtr:
@@ -1140,7 +1140,7 @@ const Type* PhiNode::Value(PhaseGVN* phase) const {
// convert the one to the other.
const TypePtr* ttp = _type->make_ptr();
const TypeInstPtr* ttip = (ttp != NULL) ? ttp->isa_instptr() : NULL;
const TypeKlassPtr* ttkp = (ttp != NULL) ? ttp->isa_klassptr() : NULL;
const TypeKlassPtr* ttkp = (ttp != NULL) ? ttp->isa_instklassptr() : NULL;
bool is_intf = false;
if (ttip != NULL) {
ciKlass* k = ttip->klass();
@@ -1233,7 +1233,7 @@ const Type* PhiNode::Value(PhaseGVN* phase) const {
// because the type system doesn't interact well with interfaces.
const TypePtr *jtp = jt->make_ptr();
const TypeInstPtr *jtip = (jtp != NULL) ? jtp->isa_instptr() : NULL;
const TypeKlassPtr *jtkp = (jtp != NULL) ? jtp->isa_klassptr() : NULL;
const TypeKlassPtr *jtkp = (jtp != NULL) ? jtp->isa_instklassptr() : NULL;
if( jtip && ttip ) {
if( jtip->is_loaded() && jtip->klass()->is_interface() &&
ttip->is_loaded() && !ttip->klass()->is_interface() ) {
@@ -1410,7 +1410,7 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
if ( offset == Type::OffsetBot || (offset >= 0 && (size_t)offset < sizeof(Klass)) ) {

tj = tk = TypeKlassPtr::make(TypePtr::NotNull,
TypeKlassPtr::OBJECT->klass(),
TypeInstKlassPtr::OBJECT->klass(),
offset);
}

@@ -1457,7 +1457,9 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
case Type::RawPtr: tj = TypeRawPtr::BOTTOM; break;
case Type::AryPtr: // do not distinguish arrays at all
case Type::InstPtr: tj = TypeInstPtr::BOTTOM; break;
case Type::KlassPtr: tj = TypeKlassPtr::OBJECT; break;
case Type::KlassPtr:
case Type::AryKlassPtr:
case Type::InstKlassPtr: tj = TypeInstKlassPtr::OBJECT; break;
case Type::AnyPtr: tj = TypePtr::BOTTOM; break; // caller checks it
default: ShouldNotReachHere();
}
@@ -916,7 +916,7 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) {
Node* ex_klass_node = NULL;
if (has_ex_handler() && !ex_type->klass_is_exact()) {
Node* p = basic_plus_adr( ex_node, ex_node, oopDesc::klass_offset_in_bytes());
ex_klass_node = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT));
ex_klass_node = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeInstPtr::KLASS, TypeInstKlassPtr::OBJECT));

// Compute the exception klass a little more cleverly.
// Obvious solution is to simple do a LoadKlass from the 'ex_node'.
@@ -925,7 +925,7 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) {
// I'm loading the class from, I can replace the LoadKlass with the
// klass constant for the exception oop.
if (ex_node->is_Phi()) {
ex_klass_node = new PhiNode(ex_node->in(0), TypeKlassPtr::OBJECT);
ex_klass_node = new PhiNode(ex_node->in(0), TypeInstKlassPtr::OBJECT);
for (uint i = 1; i < ex_node->req(); i++) {
Node* ex_in = ex_node->in(i);
if (ex_in == top() || ex_in == NULL) {
@@ -934,10 +934,10 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) {
continue;
}
Node* p = basic_plus_adr(ex_in, ex_in, oopDesc::klass_offset_in_bytes());
Node* k = _gvn.transform( LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT));
Node* k = _gvn.transform( LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeInstPtr::KLASS, TypeInstKlassPtr::OBJECT));
ex_klass_node->init_req( i, k );
}
_gvn.set_type(ex_klass_node, TypeKlassPtr::OBJECT);
_gvn.set_type(ex_klass_node, TypeInstKlassPtr::OBJECT);

}
}
@@ -3117,7 +3117,7 @@ void ConnectionGraph::split_unique_types(GrowableArray<Node *> &alloc_worklist,
// to the actual Array type.
if (alloc->is_Allocate() && n->as_Type()->type() == TypeInstPtr::NOTNULL
&& (alloc->is_AllocateArray() ||
igvn->type(alloc->in(AllocateNode::KlassNode)) != TypeKlassPtr::OBJECT)) {
igvn->type(alloc->in(AllocateNode::KlassNode)) != TypeInstKlassPtr::OBJECT)) {
Node *cast2 = NULL;
for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
Node *use = n->fast_out(i);
@@ -2867,7 +2867,7 @@ Node* Phase::gen_subtype_check(Node* subklass, Node* superklass, Node** ctrl, No
if (might_be_cache && mem != NULL) {
kmem = mem->is_MergeMem() ? mem->as_MergeMem()->memory_at(C->get_alias_index(gvn.type(p2)->is_ptr())) : mem;
}
Node *nkls = gvn.transform(LoadKlassNode::make(gvn, NULL, kmem, p2, gvn.type(p2)->is_ptr(), TypeKlassPtr::OBJECT_OR_NULL));
Node *nkls = gvn.transform(LoadKlassNode::make(gvn, NULL, kmem, p2, gvn.type(p2)->is_ptr(), TypeInstKlassPtr::OBJECT_OR_NULL));

// Compile speed common case: ARE a subtype and we canNOT fail
if( superklass == nkls )
@@ -3798,7 +3798,7 @@ Node* GraphKit::new_instance(Node* klass_node,
// (Actually, it need not be precise if this is a reflective allocation.)
// It's what we cast the result to.
const TypeKlassPtr* tklass = _gvn.type(klass_node)->isa_klassptr();
if (!tklass) tklass = TypeKlassPtr::OBJECT;
if (!tklass) tklass = TypeInstKlassPtr::OBJECT;
const TypeOopPtr* oop_type = tklass->as_instance_type();

// Now generate allocation code
@@ -545,7 +545,7 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {
} else {
print_prop(short_name, "L");
}
} else if (t->base() == Type::KlassPtr) {
} else if (t->base() == Type::KlassPtr || t->base() == Type::InstKlassPtr || t->base() == Type::AryKlassPtr) {
const TypeKlassPtr *typeKlass = t->is_klassptr();
print_prop(short_name, "CP");
} else if (t->base() == Type::Control) {
@@ -2838,7 +2838,7 @@ bool LibraryCallKit::inline_native_classID() {
IdealVariable result(ideal); __ declarations_done();
Node* kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(),
basic_plus_adr(cls, java_lang_Class::klass_offset()),
TypeRawPtr::BOTTOM, TypeKlassPtr::OBJECT_OR_NULL));
TypeRawPtr::BOTTOM, TypeInstKlassPtr::OBJECT_OR_NULL));


__ if_then(kls, BoolTest::ne, null()); {
@@ -2868,7 +2868,7 @@ bool LibraryCallKit::inline_native_classID() {
} __ else_(); {
Node* array_kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(),
basic_plus_adr(cls, java_lang_Class::array_klass_offset()),
TypeRawPtr::BOTTOM, TypeKlassPtr::OBJECT_OR_NULL));
TypeRawPtr::BOTTOM, TypeInstKlassPtr::OBJECT_OR_NULL));
__ if_then(array_kls, BoolTest::ne, null()); {
Node* array_kls_trace_id_addr = basic_plus_adr(array_kls, in_bytes(KLASS_TRACE_ID_OFFSET));
Node* array_kls_trace_id_raw = ideal.load(ideal.ctrl(), array_kls_trace_id_addr, TypeLong::LONG, T_LONG, Compile::AliasIdxRaw);
@@ -2961,7 +2961,7 @@ Node* LibraryCallKit::load_klass_from_mirror_common(Node* mirror,
int offset) {
if (region == NULL) never_see_null = true;
Node* p = basic_plus_adr(mirror, offset);
const TypeKlassPtr* kls_type = TypeKlassPtr::OBJECT_OR_NULL;
const TypeKlassPtr* kls_type = TypeInstKlassPtr::OBJECT_OR_NULL;
Node* kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeRawPtr::BOTTOM, kls_type));
Node* null_ctl = top();
kls = null_check_oop(kls, &null_ctl, never_see_null);
@@ -3150,7 +3150,7 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) {
phi->add_req(makecon(TypeInstPtr::make(env()->Object_klass()->java_mirror())));
// If we fall through, it's a plain class. Get its _super.
p = basic_plus_adr(kls, in_bytes(Klass::super_offset()));
kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeRawPtr::BOTTOM, TypeKlassPtr::OBJECT_OR_NULL));
kls = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeRawPtr::BOTTOM, TypeInstKlassPtr::OBJECT_OR_NULL));
null_ctl = top();
kls = null_check_oop(kls, &null_ctl);
if (null_ctl != top()) {
@@ -3292,7 +3292,7 @@ bool LibraryCallKit::inline_native_subtype_check() {
record_for_igvn(region);

const TypePtr* adr_type = TypeRawPtr::BOTTOM; // memory type of loads
const TypeKlassPtr* kls_type = TypeKlassPtr::OBJECT_OR_NULL;
const TypeKlassPtr* kls_type = TypeInstKlassPtr::OBJECT_OR_NULL;
int class_klass_offset = java_lang_Class::klass_offset();

// First null-check both mirrors and load each mirror's klass metaobject.
@@ -6004,7 +6004,7 @@ bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) {

ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass();
const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_AESCrypt);
const TypeOopPtr* xtype = aklass->as_instance_type();
const TypeOopPtr* xtype = aklass->as_instance_type()->cast_to_ptr_type(TypePtr::NotNull);
Node* aescrypt_object = new CheckCastPPNode(control(), embeddedCipherObj, xtype);
aescrypt_object = _gvn.transform(aescrypt_object);

@@ -6092,7 +6092,7 @@ bool LibraryCallKit::inline_electronicCodeBook_AESCrypt(vmIntrinsics::ID id) {

ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass();
const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_AESCrypt);
const TypeOopPtr* xtype = aklass->as_instance_type();
const TypeOopPtr* xtype = aklass->as_instance_type()->cast_to_ptr_type(TypePtr::NotNull);
Node* aescrypt_object = new CheckCastPPNode(control(), embeddedCipherObj, xtype);
aescrypt_object = _gvn.transform(aescrypt_object);

@@ -6163,7 +6163,7 @@ bool LibraryCallKit::inline_counterMode_AESCrypt(vmIntrinsics::ID id) {
assert(klass_AESCrypt->is_loaded(), "predicate checks that this class is loaded");
ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass();
const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_AESCrypt);
const TypeOopPtr* xtype = aklass->as_instance_type();
const TypeOopPtr* xtype = aklass->as_instance_type()->cast_to_ptr_type(TypePtr::NotNull);
Node* aescrypt_object = new CheckCastPPNode(control(), embeddedCipherObj, xtype);
aescrypt_object = _gvn.transform(aescrypt_object);
// we need to get the start of the aescrypt_object's expanded key array
@@ -6681,7 +6681,7 @@ bool LibraryCallKit::inline_digestBase_implCompressMB(Node* digestBase_obj, ciIn
const char* state_type, address stubAddr, const char *stubName,
Node* src_start, Node* ofs, Node* limit) {
const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_digestBase);
const TypeOopPtr* xtype = aklass->as_instance_type();
const TypeOopPtr* xtype = aklass->as_instance_type()->cast_to_ptr_type(TypePtr::NotNull);
Node* digest_obj = new CheckCastPPNode(control(), digestBase_obj, xtype);
digest_obj = _gvn.transform(digest_obj);

@@ -1972,7 +1972,7 @@ const Type* LoadNode::Value(PhaseGVN* phase) const {
return con_type;
}
}
} else if (tp->base() == Type::KlassPtr) {
} else if (tp->base() == Type::KlassPtr || tp->base() == Type::InstKlassPtr || tp->base() == Type::AryKlassPtr) {
assert( off != Type::OffsetBot ||
// arrays can be cast to Objects
tp->is_klassptr()->klass()->is_java_lang_Object() ||
@@ -528,7 +528,7 @@ class LoadKlassNode : public LoadPNode {

// Polymorphic factory method:
static Node* make(PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const TypePtr* at,
const TypeKlassPtr* tk = TypeKlassPtr::OBJECT);
const TypeKlassPtr* tk = TypeInstKlassPtr::OBJECT);
};

//------------------------------LoadNKlassNode---------------------------------
@@ -168,7 +168,7 @@ void Parse::array_store_check() {
if (MonomorphicArrayCheck
&& !too_many_traps(Deoptimization::Reason_array_check)
&& !tak->klass_is_exact()
&& tak != TypeKlassPtr::OBJECT) {
&& tak != TypeInstKlassPtr::OBJECT) {
// Regarding the fourth condition in the if-statement from above:
//
// If the compiler has determined that the type of array 'ary' (represented
@@ -234,7 +234,7 @@ bool SubTypeCheckNode::verify(PhaseGVN* phase) {
chk_off_X = phase->transform(new ConvI2LNode(chk_off_X));
#endif
Node* p2 = phase->transform(new AddPNode(subklass, subklass, chk_off_X));
Node* nkls = phase->transform(LoadKlassNode::make(*phase, NULL, C->immutable_memory(), p2, phase->type(p2)->is_ptr(), TypeKlassPtr::OBJECT_OR_NULL));
Node* nkls = phase->transform(LoadKlassNode::make(*phase, NULL, C->immutable_memory(), p2, phase->type(p2)->is_ptr(), TypeInstKlassPtr::OBJECT_OR_NULL));

return verify_helper(phase, nkls, cached_t);
}

1 comment on commit 1d2458d

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 1d2458d Sep 14, 2021

Please sign in to comment.