src/share/vm/opto/parse2.cpp

Print this page




  88   // and if the idx value cannot be negative:
  89   bool need_range_check = true;
  90   if (idxtype->_hi < sizetype->_lo && idxtype->_lo >= 0) {
  91     need_range_check = false;
  92     if (C->log() != NULL)   C->log()->elem("observe that='!need_range_check'");
  93   }
  94 
  95   if (!arytype->klass()->is_loaded()) {
  96     // Only fails for some -Xcomp runs
  97     // The class is unloaded.  We have to run this bytecode in the interpreter.
  98     uncommon_trap(Deoptimization::Reason_unloaded,
  99                   Deoptimization::Action_reinterpret,
 100                   arytype->klass(), "!loaded array");
 101     return top();
 102   }
 103 
 104   // Do the range check
 105   if (GenerateRangeChecks && need_range_check) {
 106     // Range is constant in array-oop, so we can use the original state of mem
 107     Node* len = load_array_length(ary);








 108     // Test length vs index (standard trick using unsigned compare)
 109     Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) );
 110     BoolTest::mask btest = BoolTest::lt;
 111     Node* tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) );

 112     // Branch to failure if out of bounds
 113     { BuildCutout unless(this, tst, PROB_MAX);
 114       if (C->allow_range_check_smearing()) {
 115         // Do not use builtin_throw, since range checks are sometimes
 116         // made more stringent by an optimistic transformation.
 117         // This creates "tentative" range checks at this point,
 118         // which are not guaranteed to throw exceptions.
 119         // See IfNode::Ideal, is_range_check, adjust_check.
 120         uncommon_trap(Deoptimization::Reason_range_check,
 121                       Deoptimization::Action_make_not_entrant,
 122                       NULL, "range_check");
 123       } else {
 124         // If we have already recompiled with the range-check-widening
 125         // heroic optimization turned off, then we must really be throwing
 126         // range check exceptions.
 127         builtin_throw(Deoptimization::Reason_range_check, idx);
 128       }
 129     }
 130   }
 131   // Check for always knowing you are throwing a range-check exception




  88   // and if the idx value cannot be negative:
  89   bool need_range_check = true;
  90   if (idxtype->_hi < sizetype->_lo && idxtype->_lo >= 0) {
  91     need_range_check = false;
  92     if (C->log() != NULL)   C->log()->elem("observe that='!need_range_check'");
  93   }
  94 
  95   if (!arytype->klass()->is_loaded()) {
  96     // Only fails for some -Xcomp runs
  97     // The class is unloaded.  We have to run this bytecode in the interpreter.
  98     uncommon_trap(Deoptimization::Reason_unloaded,
  99                   Deoptimization::Action_reinterpret,
 100                   arytype->klass(), "!loaded array");
 101     return top();
 102   }
 103 
 104   // Do the range check
 105   if (GenerateRangeChecks && need_range_check) {
 106     // Range is constant in array-oop, so we can use the original state of mem
 107     Node* len = load_array_length(ary);
 108     Node* tst;
 109     if (sizetype->_hi <= 0) {
 110       // If the greatest array bound is negative, we can conclude that we're
 111       // compiling unreachable code, but the unsigned compare trick used below 
 112       // only works with non-negative lengths.  Instead, hack "tst" to be zero so 
 113       // the uncommon_trap path will always be taken.
 114       tst = _gvn.intcon(0);
 115     } else {
 116       // Test length vs index (standard trick using unsigned compare)
 117       Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) );
 118       BoolTest::mask btest = BoolTest::lt;
 119       tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) );
 120     }
 121     // Branch to failure if out of bounds
 122     { BuildCutout unless(this, tst, PROB_MAX);
 123       if (C->allow_range_check_smearing()) {
 124         // Do not use builtin_throw, since range checks are sometimes
 125         // made more stringent by an optimistic transformation.
 126         // This creates "tentative" range checks at this point,
 127         // which are not guaranteed to throw exceptions.
 128         // See IfNode::Ideal, is_range_check, adjust_check.
 129         uncommon_trap(Deoptimization::Reason_range_check,
 130                       Deoptimization::Action_make_not_entrant,
 131                       NULL, "range_check");
 132       } else {
 133         // If we have already recompiled with the range-check-widening
 134         // heroic optimization turned off, then we must really be throwing
 135         // range check exceptions.
 136         builtin_throw(Deoptimization::Reason_range_check, idx);
 137       }
 138     }
 139   }
 140   // Check for always knowing you are throwing a range-check exception