< prev index next >

src/hotspot/share/c1/c1_Optimizer.cpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -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

@@ -197,11 +198,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);
   }

@@ -249,13 +251,14 @@
   }
 
   _hir->verify();
 }
 
-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) {

@@ -286,11 +289,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();

@@ -302,11 +305,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());

@@ -434,11 +437,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(), if_->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);

@@ -506,13 +509,16 @@
   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_NewValueTypeInstance(NewValueTypeInstance* x);
   void do_NewTypeArray   (NewTypeArray*    x);
   void do_NewObjectArray (NewObjectArray*  x);
   void do_NewMultiArray  (NewMultiArray*   x);
+  void do_WithField      (WithField*       x);
+  void do_DefaultValue   (DefaultValue*    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);

@@ -654,10 +660,11 @@
   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_NewValueTypeInstance(NewValueTypeInstance* 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);

@@ -692,13 +699,16 @@
 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_NewValueTypeInstance(NewValueTypeInstance*     x) { nce()->handle_NewValueTypeInstance(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_WithField      (WithField*       x) {}
+void NullCheckVisitor::do_DefaultValue   (DefaultValue*    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);     }

@@ -866,11 +876,11 @@
       // the non-null map
       ciField* field = x->field();
       if (field->is_constant()) {
         ciConstant field_val = field->constant_value();
         BasicType field_type = field_val.basic_type();
-        if (field_type == T_OBJECT || field_type == T_ARRAY) {
+        if (field_type == T_OBJECT || field_type == T_ARRAY || field_type == T_VALUETYPE) {
           ciObject* obj_val = field_val.as_object();
           if (!obj_val->is_null_object()) {
             if (PrintNullCheckElimination) {
               tty->print_cr("AccessField %d proven non-null by static final non-null oop check",
                             x->id());

@@ -1044,10 +1054,17 @@
   if (PrintNullCheckElimination) {
     tty->print_cr("NewInstance %d is non-null", x->id());
   }
 }
 
+void NullCheckEliminator::handle_NewValueTypeInstance(NewValueTypeInstance* x) {
+  set_put(x);
+  if (PrintNullCheckElimination) {
+    tty->print_cr("NewValueTypeInstance %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());
< prev index next >