8181741: C2 compilation fails with "assert(i<_max) failed: oob"
authorthartmann
Fri, 09 Jun 2017 09:27:10 +0200
changeset 46532 7c122c98399d
parent 46531 f78769631206
child 46533 589d3ba9fcf0
child 46582 e00b3e229f11
8181741: C2 compilation fails with "assert(i<_max) failed: oob" Summary: PhaseIdealLoop should not use type() or type_or_null(). Reviewed-by: roland, kvn
hotspot/src/share/vm/opto/castnode.cpp
hotspot/src/share/vm/opto/castnode.hpp
hotspot/src/share/vm/opto/loopopts.cpp
hotspot/src/share/vm/opto/phaseX.hpp
--- a/hotspot/src/share/vm/opto/castnode.cpp	Fri Jun 09 09:20:13 2017 +0200
+++ b/hotspot/src/share/vm/opto/castnode.cpp	Fri Jun 09 09:27:10 2017 +0200
@@ -35,7 +35,7 @@
 //=============================================================================
 // If input is already higher or equal to cast type, then this is an identity.
 Node* ConstraintCastNode::Identity(PhaseGVN* phase) {
-  Node* dom = dominating_cast(phase);
+  Node* dom = dominating_cast(phase, phase);
   if (dom != NULL) {
     return dom;
   }
@@ -108,7 +108,7 @@
   return NULL;
 }
 
-TypeNode* ConstraintCastNode::dominating_cast(PhaseTransform *phase) const {
+TypeNode* ConstraintCastNode::dominating_cast(PhaseGVN* gvn, PhaseTransform* pt) const {
   Node* val = in(1);
   Node* ctl = in(0);
   int opc = Opcode();
@@ -121,7 +121,7 @@
   if (is_CastII() && as_CastII()->has_range_check()) {
     return NULL;
   }
-  if (type()->isa_rawptr() && (phase->type_or_null(val) == NULL || phase->type(val)->isa_oopptr())) {
+  if (type()->isa_rawptr() && (gvn->type_or_null(val) == NULL || gvn->type(val)->isa_oopptr())) {
     return NULL;
   }
   for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
@@ -131,7 +131,7 @@
         u->Opcode() == opc &&
         u->in(0) != NULL &&
         u->bottom_type()->higher_equal(type())) {
-      if (phase->is_dominator(u->in(0), ctl)) {
+      if (pt->is_dominator(u->in(0), ctl)) {
         return u->as_Type();
       }
       if (is_CheckCastPP() && u->in(1)->is_Proj() && u->in(1)->in(0)->is_Allocate() &&
@@ -283,7 +283,7 @@
 //------------------------------Identity---------------------------------------
 // If input is already higher or equal to cast type, then this is an identity.
 Node* CheckCastPPNode::Identity(PhaseGVN* phase) {
-  Node* dom = dominating_cast(phase);
+  Node* dom = dominating_cast(phase, phase);
   if (dom != NULL) {
     return dom;
   }
--- a/hotspot/src/share/vm/opto/castnode.hpp	Fri Jun 09 09:20:13 2017 +0200
+++ b/hotspot/src/share/vm/opto/castnode.hpp	Fri Jun 09 09:27:10 2017 +0200
@@ -51,7 +51,7 @@
   virtual uint ideal_reg() const = 0;
   virtual bool depends_only_on_test() const { return !_carry_dependency; }
   bool carry_dependency() const { return _carry_dependency; }
-  TypeNode* dominating_cast(PhaseTransform *phase) const;
+  TypeNode* dominating_cast(PhaseGVN* gvn, PhaseTransform* pt) const;
   static Node* make_cast(int opcode,  Node* c, Node *n, const Type *t, bool carry_dependency);
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/opto/loopopts.cpp	Fri Jun 09 09:20:13 2017 +0200
+++ b/hotspot/src/share/vm/opto/loopopts.cpp	Fri Jun 09 09:27:10 2017 +0200
@@ -912,7 +912,7 @@
   if( m ) return m;
 
   if (n->is_ConstraintCast()) {
-    Node* dom_cast = n->as_ConstraintCast()->dominating_cast(this);
+    Node* dom_cast = n->as_ConstraintCast()->dominating_cast(&_igvn, this);
     if (dom_cast != NULL) {
       _igvn.replace_node(n, dom_cast);
       return dom_cast;
--- a/hotspot/src/share/vm/opto/phaseX.hpp	Fri Jun 09 09:20:13 2017 +0200
+++ b/hotspot/src/share/vm/opto/phaseX.hpp	Fri Jun 09 09:27:10 2017 +0200
@@ -211,6 +211,7 @@
   // If you want the type of a very new (untransformed) node,
   // you must use type_or_null, and test the result for NULL.
   const Type* type(const Node* n) const {
+    assert(_pnum != Ideal_Loop, "should not be used from PhaseIdealLoop");
     assert(n != NULL, "must not be null");
     const Type* t = _types.fast_lookup(n->_idx);
     assert(t != NULL, "must set before get");
@@ -219,6 +220,7 @@
   // Get a previously recorded type for the node n,
   // or else return NULL if there is none.
   const Type* type_or_null(const Node* n) const {
+    assert(_pnum != Ideal_Loop, "should not be used from PhaseIdealLoop");
     return _types.fast_lookup(n->_idx);
   }
   // Record a type for a node.