< 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);

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