8213371: GC/C2 abstraction and cleanup to handle custom offset for GC memory accesses
authorrkennke
Wed, 07 Nov 2018 20:21:35 +0100
changeset 52441 6082c529aed8
parent 52440 f6583d7cff56
child 52442 dc1f9dec2018
8213371: GC/C2 abstraction and cleanup to handle custom offset for GC memory accesses Reviewed-by: kvn, roland
src/hotspot/share/gc/shared/c2/barrierSetC2.hpp
src/hotspot/share/opto/compile.cpp
src/hotspot/share/opto/memnode.cpp
src/hotspot/share/opto/type.cpp
--- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp	Thu Nov 01 11:42:59 2018 -0400
+++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp	Wed Nov 07 20:21:35 2018 +0100
@@ -283,6 +283,11 @@
     BeforeCodeGen
   };
   virtual void verify_gc_barriers(Compile* compile, CompilePhase phase) 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
--- a/src/hotspot/share/opto/compile.cpp	Thu Nov 01 11:42:59 2018 -0400
+++ b/src/hotspot/share/opto/compile.cpp	Wed Nov 07 20:21:35 2018 +0100
@@ -1468,6 +1468,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);
@@ -1532,6 +1534,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.
@@ -1630,7 +1634,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 &&
--- a/src/hotspot/share/opto/memnode.cpp	Thu Nov 01 11:42:59 2018 -0400
+++ b/src/hotspot/share/opto/memnode.cpp	Wed Nov 07 20:21:35 2018 +0100
@@ -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()) {
@@ -1734,7 +1734,7 @@
         && Opcode() != Op_LoadKlass && Opcode() != Op_LoadNKlass) {
       // t might actually be lower than _type, if _type is a unique
       // concrete subclass of abstract class t.
-      if (off_beyond_header) {  // is the offset beyond the header?
+      if (off_beyond_header || off == Type::OffsetBot) {  // is the offset beyond the header?
         const Type* jt = t->join_speculative(_type);
         // In any case, do not allow the join, per se, to empty out the type.
         if (jt->empty() && !t->empty()) {
--- a/src/hotspot/share/opto/type.cpp	Thu Nov 01 11:42:59 2018 -0400
+++ b/src/hotspot/share/opto/type.cpp	Wed Nov 07 20:21:35 2018 +0100
@@ -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) {