changeset 4502:d595e8ddadd9

8010934: assert failure in c1_LinearScan.cpp: "asumption: non-Constant instructions have only virtual operands" Summary: incorrect code to skip some ArrayLength instructions in LIRGenerator Reviewed-by: kvn
author roland
date Fri, 29 Mar 2013 17:25:27 +0100
parents 30f42e691e70
children cd9ad42dfde0
files src/share/vm/c1/c1_LIRGenerator.cpp src/share/vm/c1/c1_RangeCheckElimination.cpp
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/c1/c1_LIRGenerator.cpp	Tue Mar 26 12:55:26 2013 -0700
+++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Fri Mar 29 17:25:27 2013 +0100
@@ -1872,8 +1872,6 @@
 
 
 void LIRGenerator::do_ArrayLength(ArrayLength* x) {
-  if (x->use_count() == 0 && !x->can_trap()) return;
-
   LIRItem array(x->array(), this);
   array.load_item();
   LIR_Opr reg = rlock_result(x);
--- a/src/share/vm/c1/c1_RangeCheckElimination.cpp	Tue Mar 26 12:55:26 2013 -0700
+++ b/src/share/vm/c1/c1_RangeCheckElimination.cpp	Fri Mar 29 17:25:27 2013 +0100
@@ -645,7 +645,7 @@
   return predicate_add(left, left_const, cond, const_instr, state, insert_position);
 }
 
-// Insert deoptimization, returns true if sucessful or false if range check should not be removed
+// Insert deoptimization
 void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction *insert_position, Instruction *array_instr, Instruction *length_instr, Instruction *lower_instr, int lower, Instruction *upper_instr, int upper, AccessIndexed *ai) {
   assert(is_ok_for_deoptimization(insert_position, array_instr, length_instr, lower_instr, lower, upper_instr, upper), "should have been tested before");
   bool upper_check = !(upper_instr && upper_instr->as_ArrayLength() && upper_instr->as_ArrayLength()->array() == array_instr);
@@ -669,6 +669,9 @@
     }
   }
 
+  // No upper check required -> skip
+  if (!upper_check) return;
+
   // We need to know length of array
   if (!length_instr) {
     // Load length if necessary
@@ -680,9 +683,6 @@
     length_instr = length;
   }
 
-  // No upper check required -> skip
-  if (!upper_check) return;
-
   if (!upper_instr) {
     // Compare for geq array.length
     insert_position = predicate_cmp_with_const(length_instr, Instruction::leq, upper, state, insert_position, bci);
@@ -777,7 +777,7 @@
     tty->fill_to(block->dominator_depth()*2)
   );
   TRACE_RANGE_CHECK_ELIMINATION(
-    tty->print_cr("Access indexed: index=%d length=%d", ai->index()->id(), ai->length()->id())
+    tty->print_cr("Access indexed: index=%d length=%d", ai->index()->id(), (ai->length() != NULL ? ai->length()->id() :-1 ))
   );
 
   if (ai->check_flag(Instruction::NeedsRangeCheckFlag)) {