# HG changeset patch # User rkennke # Date 1541431701 -3600 # Mon Nov 05 16:28:21 2018 +0100 # Node ID 38c671d1188cf2f6f04d3a08da7b02c5b5b3e6c6 # Parent 6d42c07ba238ba5f4db0bfe5dd481ed1a15795b0 8213371: GC/C2 abstraction and cleanup to handle custom offset for GC memory accesses diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp @@ -224,6 +224,11 @@ // expanded later, then now is the time to do so. virtual bool expand_macro_nodes(PhaseMacroExpand* macro) const { return false; } virtual void verify_gc_barriers(bool post_parse) const {} + + virtual bool flatten_gc_alias_type(const TypePtr*& adr_type) const { return false; } +#ifdef ASSERT + virtual bool verify_gc_alias_type(const TypePtr* adr_type, int offset) const { return false; } +#endif }; #endif // SHARE_GC_SHARED_C2_BARRIERSETC2_HPP diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -1465,6 +1465,8 @@ tj = TypeInstPtr::MARK; ta = TypeAryPtr::RANGE; // generic ignored junk ptr = TypePtr::BotPTR; + } else if (BarrierSet::barrier_set()->barrier_set_c2()->flatten_gc_alias_type(tj)) { + ta = tj->isa_aryptr(); } else { // Random constant offset into array body offset = Type::OffsetBot; // Flatten constant access into array body tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset); @@ -1529,6 +1531,8 @@ if (!is_known_inst) { // Do it only for non-instance types tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset); } + } else if (BarrierSet::barrier_set()->barrier_set_c2()->flatten_gc_alias_type(tj)) { + to = tj->is_instptr(); } else if (offset < 0 || offset >= k->size_helper() * wordSize) { // Static fields are in the space above the normal instance // fields in the java.lang.Class instance. @@ -1627,7 +1631,8 @@ (offset == Type::OffsetBot && tj == TypePtr::BOTTOM) || (offset == oopDesc::mark_offset_in_bytes() && tj->base() == Type::AryPtr) || (offset == oopDesc::klass_offset_in_bytes() && tj->base() == Type::AryPtr) || - (offset == arrayOopDesc::length_offset_in_bytes() && tj->base() == Type::AryPtr) , + (offset == arrayOopDesc::length_offset_in_bytes() && tj->base() == Type::AryPtr) || + (BarrierSet::barrier_set()->barrier_set_c2()->verify_gc_alias_type(tj, offset)), "For oops, klasses, raw offset must be constant; for arrays the offset is never known" ); assert( tj->ptr() != TypePtr::TopPTR && tj->ptr() != TypePtr::AnyNull && diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -1697,7 +1697,7 @@ // as to alignment, which will therefore produce the smallest // possible base offset. const int min_base_off = arrayOopDesc::base_offset_in_bytes(T_BYTE); - const bool off_beyond_header = ((uint)off >= (uint)min_base_off); + const bool off_beyond_header = (off >= min_base_off); // Try to constant-fold a stable array element. if (FoldStableValues && !is_mismatched_access() && ary->is_stable()) { diff --git a/src/hotspot/share/opto/type.cpp b/src/hotspot/share/opto/type.cpp --- a/src/hotspot/share/opto/type.cpp +++ b/src/hotspot/share/opto/type.cpp @@ -2960,7 +2960,7 @@ _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); } #ifdef _LP64 - if (_offset != 0) { + 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) {