changeset 9640:6f3baccef211

8141044: C1 should fold (this == null) to false Reviewed-by: jrose, roland
author shade
date Thu, 05 Nov 2015 13:33:18 +0300
parents 40bd4478a362
children f6fe5d638924
files src/share/vm/c1/c1_Canonicalizer.cpp src/share/vm/c1/c1_GraphBuilder.cpp src/share/vm/c1/c1_Instruction.hpp
diffstat 3 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/c1/c1_Canonicalizer.cpp	Wed Nov 04 07:23:23 2015 -1000
+++ b/src/share/vm/c1/c1_Canonicalizer.cpp	Thu Nov 05 13:33:18 2015 +0300
@@ -727,7 +727,9 @@
         set_canonical(new IfInstanceOf(inst->klass(), inst->obj(), true, inst->state_before()->bci(), is_inst_sux, no_inst_sux));
       }
     }
-  } else if (rt == objectNull && (l->as_NewInstance() || l->as_NewArray())) {
+  } else if (rt == objectNull &&
+           (l->as_NewInstance() || l->as_NewArray() ||
+             (UseNewCode && l->as_Local() && l->as_Local()->is_receiver()))) {
     if (x->cond() == Instruction::eql) {
       BlockBegin* sux = x->fsux();
       set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
--- a/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Nov 04 07:23:23 2015 -1000
+++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Nov 05 13:33:18 2015 +0300
@@ -3089,7 +3089,7 @@
   int idx = 0;
   if (!method()->is_static()) {
     // we should always see the receiver
-    state->store_local(idx, new Local(method()->holder(), objectType, idx));
+    state->store_local(idx, new Local(method()->holder(), objectType, idx, true));
     idx = 1;
   }
 
@@ -3101,7 +3101,7 @@
     // don't allow T_ARRAY to propagate into locals types
     if (basic_type == T_ARRAY) basic_type = T_OBJECT;
     ValueType* vt = as_ValueType(basic_type);
-    state->store_local(idx, new Local(type, vt, idx));
+    state->store_local(idx, new Local(type, vt, idx, false));
     idx += type->size();
   }
 
--- a/src/share/vm/c1/c1_Instruction.hpp	Wed Nov 04 07:23:23 2015 -1000
+++ b/src/share/vm/c1/c1_Instruction.hpp	Thu Nov 05 13:33:18 2015 +0300
@@ -701,19 +701,22 @@
 LEAF(Local, Instruction)
  private:
   int      _java_index;                          // the local index within the method to which the local belongs
+  bool     _is_receiver;                         // if local variable holds the receiver: "this" for non-static methods
   ciType*  _declared_type;
  public:
   // creation
-  Local(ciType* declared, ValueType* type, int index)
+  Local(ciType* declared, ValueType* type, int index, bool receiver)
     : Instruction(type)
     , _java_index(index)
     , _declared_type(declared)
+    , _is_receiver(receiver)
   {
     NOT_PRODUCT(set_printable_bci(-1));
   }
 
   // accessors
   int java_index() const                         { return _java_index; }
+  bool is_receiver() const                       { return _is_receiver; }
 
   virtual ciType* declared_type() const          { return _declared_type; }