< prev index next >

src/hotspot/share/opto/subtypenode.cpp

Print this page
@@ -44,24 +44,43 @@
        Compile::current()->dependencies()->assert_leaf_type(superklass);
        return TypeInt::CC_GT;
      }
    }
  
-   if (subk != nullptr) {
-     switch (Compile::current()->static_subtype_check(superk, subk, false)) {
-       case Compile::SSC_always_false:
-         return TypeInt::CC_GT;
-       case Compile::SSC_always_true:
-         return TypeInt::CC_EQ;
-       case Compile::SSC_easy_test:
-       case Compile::SSC_full_test:
-         break;
-       default:
-         ShouldNotReachHere();
+   // FIXME: shouldn't this be encoded in helper methods of the type system (maybe_java_subtype_of() etc.?)
+   // Similar to logic in CmpPNode::sub()
+   bool unrelated_classes = false;
+   // Handle inline type arrays
+   if (subk->flat_in_array() && superk->not_flat_in_array_inexact()) {
+     // The subtype is in flat arrays and the supertype is not in flat arrays and no subklass can be. Must be unrelated.
+     unrelated_classes = true;
+   } else if (subk->is_not_flat() && superk->is_flat()) {
+     // The subtype is a non-flat array and the supertype is a flat array. Must be unrelated.
+     unrelated_classes = true;
+   } else if (subk->is_not_null_free() && superk->is_null_free()) {
+     // The subtype is a nullable array and the supertype is null-free array. Must be unrelated.
+     unrelated_classes = true;
+   }
+   if (unrelated_classes) {
+     TypePtr::PTR jp = sub_t->is_ptr()->join_ptr(super_t->is_ptr()->_ptr);
+     if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
+       return TypeInt::CC_GT;
      }
    }
  
+   switch (Compile::current()->static_subtype_check(superk, subk, false)) {
+     case Compile::SSC_always_false:
+       return TypeInt::CC_GT;
+     case Compile::SSC_always_true:
+       return TypeInt::CC_EQ;
+     case Compile::SSC_easy_test:
+     case Compile::SSC_full_test:
+       break;
+     default:
+       ShouldNotReachHere();
+   }
+ 
    return bottom_type();
  }
  
  Node *SubTypeCheckNode::Ideal(PhaseGVN* phase, bool can_reshape) {
    Node* obj_or_subklass = in(ObjOrSubKlass);

@@ -185,11 +204,12 @@
          Node* p1 = phase->transform(new AddPNode(superklass, superklass, phase->MakeConX(in_bytes(Klass::super_check_offset_offset()))));
          Node* chk_off = phase->transform(new LoadINode(nullptr, C->immutable_memory(), p1, phase->type(p1)->is_ptr(), TypeInt::INT, MemNode::unordered));
          record_for_cleanup(chk_off, phase);
  
          int cacheoff_con = in_bytes(Klass::secondary_super_cache_offset());
-         bool might_be_cache = (phase->find_int_con(chk_off, cacheoff_con) == cacheoff_con);
+         // TODO 8366668 Re-enable. This breaks TestArrays.java with -XX:+StressReflectiveCode
+         bool might_be_cache = true; // (phase->find_int_con(chk_off, cacheoff_con) == cacheoff_con);
          if (!might_be_cache) {
            Node* subklass = load_klass(phase);
            Node* chk_off_X = chk_off;
  #ifdef _LP64
            chk_off_X = phase->transform(new ConvI2LNode(chk_off_X));

@@ -241,6 +261,6 @@
      st->print(" profiled at:");
      _method->print_short_name(st);
      st->print(":%d", _bci);
    }
  }
- #endif
+ #endif
< prev index next >