< prev index next >

src/hotspot/share/c1/c1_Optimizer.cpp

Print this page
@@ -87,11 +87,12 @@
    }
  
    virtual void block_do(BlockBegin* block);
  
   private:
-   Value make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval);
+   Value make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval,
+                   ValueStack* state_before, bool substitutability_check);
  };
  
  void CE_Eliminator::block_do(BlockBegin* block) {
    // 1) find conditional expression
    // check if block ends with an If

@@ -216,11 +217,12 @@
      f_value = new Constant(f_const->type());
      NOT_PRODUCT(f_value->set_printable_bci(if_->printable_bci()));
      cur_end = cur_end->set_next(f_value);
    }
  
-   Value result = make_ifop(if_->x(), if_->cond(), if_->y(), t_value, f_value);
+   Value result = make_ifop(if_->x(), if_->cond(), if_->y(), t_value, f_value,
+                            if_->state_before(), if_->substitutability_check());
    assert(result != NULL, "make_ifop must return a non-null instruction");
    if (!result->is_linked() && result->can_be_linked()) {
      NOT_PRODUCT(result->set_printable_bci(if_->printable_bci()));
      cur_end = cur_end->set_next(result);
    }

@@ -271,13 +273,14 @@
    _hir->verify_local(blocks_to_verify_later);
  #endif // DO_DELAYED_VERIFICATION
  
  }
  
- Value CE_Eliminator::make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval) {
+ Value CE_Eliminator::make_ifop(Value x, Instruction::Condition cond, Value y, Value tval, Value fval,
+                                ValueStack* state_before, bool substitutability_check) {
    if (!OptimizeIfOps) {
-     return new IfOp(x, cond, y, tval, fval);
+     return new IfOp(x, cond, y, tval, fval, state_before, substitutability_check);
    }
  
    tval = tval->subst();
    fval = fval->subst();
    if (tval == fval) {

@@ -308,11 +311,11 @@
  
            _ifop_count++;
            if (new_tval == new_fval) {
              return new_tval;
            } else {
-             return new IfOp(x_ifop->x(), x_ifop_cond, x_ifop->y(), new_tval, new_fval);
+             return new IfOp(x_ifop->x(), x_ifop_cond, x_ifop->y(), new_tval, new_fval, state_before, substitutability_check);
            }
          }
        }
      } else {
        Constant* x_const = x->as_Constant();

@@ -324,11 +327,11 @@
            return x_compare_res == Constant::cond_true ? tval : fval;
          }
        }
      }
    }
-   return new IfOp(x, cond, y, tval, fval);
+   return new IfOp(x, cond, y, tval, fval, state_before, substitutability_check);
  }
  
  void Optimizer::eliminate_conditional_expressions() {
    // find conditional expressions & replace them with IfOps
    CE_Eliminator ce(ir());

@@ -464,11 +467,11 @@
        if (!con || !ifop) {
          ifop = if_->y()->as_IfOp();
          con  = if_->x()->as_Constant();
          swapped = true;
        }
-       if (con && ifop) {
+       if (con && ifop && !ifop->substitutability_check()) {
          Constant* tval = ifop->tval()->as_Constant();
          Constant* fval = ifop->fval()->as_Constant();
          if (tval && fval) {
            // Find the instruction before if_, starting with ifop.
            // When if_ and ifop are not in the same block, prev

@@ -489,11 +492,11 @@
  
              BlockBegin* tblock = tval->compare(cond, con, tsux, fsux);
              BlockBegin* fblock = fval->compare(cond, con, tsux, fsux);
              if (tblock != fblock && !if_->is_safepoint()) {
                If* newif = new If(ifop->x(), ifop->cond(), false, ifop->y(),
-                                  tblock, fblock, if_->state_before(), if_->is_safepoint());
+                                  tblock, fblock, if_->state_before(), if_->is_safepoint(), ifop->substitutability_check());
                newif->set_state(if_->state()->copy());
  
                assert(prev->next() == if_, "must be guaranteed by above search");
                NOT_PRODUCT(newif->set_printable_bci(if_->printable_bci()));
                prev->set_next(newif);

@@ -560,13 +563,15 @@
    void do_Convert        (Convert*         x);
    void do_NullCheck      (NullCheck*       x);
    void do_TypeCast       (TypeCast*        x);
    void do_Invoke         (Invoke*          x);
    void do_NewInstance    (NewInstance*     x);
+   void do_NewInlineTypeInstance(NewInlineTypeInstance* x);
    void do_NewTypeArray   (NewTypeArray*    x);
    void do_NewObjectArray (NewObjectArray*  x);
    void do_NewMultiArray  (NewMultiArray*   x);
+   void do_Deoptimize     (Deoptimize*      x);
    void do_CheckCast      (CheckCast*       x);
    void do_InstanceOf     (InstanceOf*      x);
    void do_MonitorEnter   (MonitorEnter*    x);
    void do_MonitorExit    (MonitorExit*     x);
    void do_Intrinsic      (Intrinsic*       x);

@@ -584,10 +589,11 @@
    void do_UnsafeGet      (UnsafeGet*       x);
    void do_UnsafePut      (UnsafePut*       x);
    void do_UnsafeGetAndSet(UnsafeGetAndSet* x);
    void do_ProfileCall    (ProfileCall*     x);
    void do_ProfileReturnType (ProfileReturnType*  x);
+   void do_ProfileACmpTypes(ProfileACmpTypes*  x);
    void do_ProfileInvoke  (ProfileInvoke*   x);
    void do_RuntimeCall    (RuntimeCall*     x);
    void do_MemBar         (MemBar*          x);
    void do_RangeCheckPredicate(RangeCheckPredicate* x);
  #ifdef ASSERT

@@ -705,17 +711,19 @@
    void handle_LoadIndexed     (LoadIndexed* x);
    void handle_StoreIndexed    (StoreIndexed* x);
    void handle_NullCheck       (NullCheck* x);
    void handle_Invoke          (Invoke* x);
    void handle_NewInstance     (NewInstance* x);
+   void handle_NewInlineTypeInstance(NewInlineTypeInstance* x);
    void handle_NewArray        (NewArray* x);
    void handle_AccessMonitor   (AccessMonitor* x);
    void handle_Intrinsic       (Intrinsic* x);
    void handle_ExceptionObject (ExceptionObject* x);
    void handle_Phi             (Phi* x);
    void handle_ProfileCall     (ProfileCall* x);
    void handle_ProfileReturnType (ProfileReturnType* x);
+   void handle_ProfileACmpTypes(ProfileACmpTypes* x);
  };
  
  
  // NEEDS_CLEANUP
  // There may be other instructions which need to clear the last

@@ -743,13 +751,15 @@
  void NullCheckVisitor::do_Convert        (Convert*         x) {}
  void NullCheckVisitor::do_NullCheck      (NullCheck*       x) { nce()->handle_NullCheck(x); }
  void NullCheckVisitor::do_TypeCast       (TypeCast*        x) {}
  void NullCheckVisitor::do_Invoke         (Invoke*          x) { nce()->handle_Invoke(x); }
  void NullCheckVisitor::do_NewInstance    (NewInstance*     x) { nce()->handle_NewInstance(x); }
+ void NullCheckVisitor::do_NewInlineTypeInstance(NewInlineTypeInstance* x) { nce()->handle_NewInlineTypeInstance(x); }
  void NullCheckVisitor::do_NewTypeArray   (NewTypeArray*    x) { nce()->handle_NewArray(x); }
  void NullCheckVisitor::do_NewObjectArray (NewObjectArray*  x) { nce()->handle_NewArray(x); }
  void NullCheckVisitor::do_NewMultiArray  (NewMultiArray*   x) { nce()->handle_NewArray(x); }
+ void NullCheckVisitor::do_Deoptimize     (Deoptimize*      x) {}
  void NullCheckVisitor::do_CheckCast      (CheckCast*       x) { nce()->clear_last_explicit_null_check(); }
  void NullCheckVisitor::do_InstanceOf     (InstanceOf*      x) {}
  void NullCheckVisitor::do_MonitorEnter   (MonitorEnter*    x) { nce()->handle_AccessMonitor(x); }
  void NullCheckVisitor::do_MonitorExit    (MonitorExit*     x) { nce()->handle_AccessMonitor(x); }
  void NullCheckVisitor::do_Intrinsic      (Intrinsic*       x) { nce()->handle_Intrinsic(x);     }

@@ -769,10 +779,11 @@
  void NullCheckVisitor::do_UnsafeGetAndSet(UnsafeGetAndSet* x) {}
  void NullCheckVisitor::do_ProfileCall    (ProfileCall*     x) { nce()->clear_last_explicit_null_check();
                                                                  nce()->handle_ProfileCall(x); }
  void NullCheckVisitor::do_ProfileReturnType (ProfileReturnType* x) { nce()->handle_ProfileReturnType(x); }
  void NullCheckVisitor::do_ProfileInvoke  (ProfileInvoke*   x) {}
+ void NullCheckVisitor::do_ProfileACmpTypes(ProfileACmpTypes* x) { nce()->handle_ProfileACmpTypes(x); }
  void NullCheckVisitor::do_RuntimeCall    (RuntimeCall*     x) {}
  void NullCheckVisitor::do_MemBar         (MemBar*          x) {}
  void NullCheckVisitor::do_RangeCheckPredicate(RangeCheckPredicate* x) {}
  #ifdef ASSERT
  void NullCheckVisitor::do_Assert         (Assert*          x) {}

@@ -1092,10 +1103,17 @@
    if (PrintNullCheckElimination) {
      tty->print_cr("NewInstance %d is non-null", x->id());
    }
  }
  
+ void NullCheckEliminator::handle_NewInlineTypeInstance(NewInlineTypeInstance* x) {
+   set_put(x);
+   if (PrintNullCheckElimination) {
+     tty->print_cr("NewInlineTypeInstance %d is non-null", x->id());
+   }
+ }
+ 
  
  void NullCheckEliminator::handle_NewArray(NewArray* x) {
    set_put(x);
    if (PrintNullCheckElimination) {
      tty->print_cr("NewArray %d is non-null", x->id());

@@ -1196,10 +1214,15 @@
  
  void NullCheckEliminator::handle_ProfileReturnType(ProfileReturnType* x) {
    x->set_needs_null_check(!set_contains(x->ret()));
  }
  
+ void NullCheckEliminator::handle_ProfileACmpTypes(ProfileACmpTypes* x) {
+   x->set_left_maybe_null(!set_contains(x->left()));
+   x->set_right_maybe_null(!set_contains(x->right()));
+ }
+ 
  void Optimizer::eliminate_null_checks() {
    ResourceMark rm;
  
    NullCheckEliminator nce(this);
  
< prev index next >