< prev index next >

src/share/vm/opto/parse2.cpp

Print this page

        

@@ -164,11 +164,13 @@
     }
   }
   // Check for always knowing you are throwing a range-check exception
   if (stopped())  return top();
 
-  Node* ptr = array_element_address(ary, idx, type, sizetype);
+  // Make array address computation control dependent to prevent it
+  // from floating above the range check during loop optimizations.
+  Node* ptr = array_element_address(ary, idx, type, sizetype, control());
 
   if (result2 != NULL)  *result2 = elemtype;
 
   assert(ptr != top(), "top should go hand-in-hand with stopped");
 

@@ -464,16 +466,18 @@
 
   // Create an ideal node JumpTable that has projections
   // of all possible ranges for a switch statement
   // The key_val input must be converted to a pointer offset and scaled.
   // Compare Parse::array_addressing above.
-#ifdef _LP64
+
   // Clean the 32-bit int into a real 64-bit offset.
   // Otherwise, the jint value 0 might turn into an offset of 0x0800000000.
-  const TypeLong* lkeytype = TypeLong::make(CONST64(0), num_cases-1, Type::WidenMin);
-  key_val       = _gvn.transform( new ConvI2LNode(key_val, lkeytype) );
-#endif
+  const TypeInt* ikeytype = TypeInt::make(0, num_cases, Type::WidenMin);
+  // Make I2L conversion control dependent to prevent it from
+  // floating above the range check during loop optimizations.
+  key_val = C->conv_I2X_index(&_gvn, key_val, ikeytype, control());
+
   // Shift the value by wordsize so we have an index into the table, rather
   // than a switch value
   Node *shiftWord = _gvn.MakeConX(wordSize);
   key_val = _gvn.transform( new MulXNode( key_val, shiftWord));
 
< prev index next >