6667580: Optimize CmpP for allocations
authorkvn
Fri, 29 Feb 2008 09:57:18 -0800
changeset 206 d61cf247afd5
parent 205 4069fc169258
child 207 694076d0755f
6667580: Optimize CmpP for allocations Summary: CmpP could be optimized out if it compares new allocated objects. Reviewed-by: jrose, never, rasbold
hotspot/src/share/vm/includeDB_compiler2
hotspot/src/share/vm/opto/callnode.hpp
hotspot/src/share/vm/opto/memnode.hpp
hotspot/src/share/vm/opto/node.hpp
hotspot/src/share/vm/opto/subnode.cpp
--- a/hotspot/src/share/vm/includeDB_compiler2	Thu Feb 28 15:40:09 2008 -0800
+++ b/hotspot/src/share/vm/includeDB_compiler2	Fri Feb 29 09:57:18 2008 -0800
@@ -19,7 +19,7 @@
 // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 // CA 95054 USA or visit www.sun.com if you need additional information or
 // have any questions.
-//  
+//
 //
 
 ad_<arch_model>.cpp                     adGlobals_<arch_model>.hpp
@@ -990,6 +990,7 @@
 
 subnode.cpp                             addnode.hpp
 subnode.cpp                             allocation.inline.hpp
+subnode.cpp                             callnode.hpp
 subnode.cpp                             cfgnode.hpp
 subnode.cpp                             compileLog.hpp
 subnode.cpp                             connode.hpp
@@ -1086,7 +1087,7 @@
 idealGraphPrinter.hpp                   ostream.hpp
 
 idealGraphPrinter.cpp                   idealGraphPrinter.hpp
-idealGraphPrinter.cpp			chaitin.hpp
+idealGraphPrinter.cpp                   chaitin.hpp
 idealGraphPrinter.cpp                   machnode.hpp
 idealGraphPrinter.cpp                   parse.hpp
 idealGraphPrinter.cpp                   threadCritical.hpp
@@ -1098,4 +1099,4 @@
 parse1.cpp                              idealGraphPrinter.hpp
 matcher.cpp                             idealGraphPrinter.hpp
 loopnode.cpp                            idealGraphPrinter.hpp
-chaitin.cpp				idealGraphPrinter.hpp
+chaitin.cpp                             idealGraphPrinter.hpp
--- a/hotspot/src/share/vm/opto/callnode.hpp	Thu Feb 28 15:40:09 2008 -0800
+++ b/hotspot/src/share/vm/opto/callnode.hpp	Fri Feb 29 09:57:18 2008 -0800
@@ -38,7 +38,7 @@
 class       CallLeafNode;
 class         CallLeafNoFPNode;
 class     AllocateNode;
-class     AllocateArrayNode;
+class       AllocateArrayNode;
 class     LockNode;
 class     UnlockNode;
 class JVMState;
@@ -91,7 +91,9 @@
 class ParmNode : public ProjNode {
   static const char * const names[TypeFunc::Parms+1];
 public:
-  ParmNode( StartNode *src, uint con ) : ProjNode(src,con) {}
+  ParmNode( StartNode *src, uint con ) : ProjNode(src,con) {
+    init_class_id(Class_Parm);
+  }
   virtual int Opcode() const;
   virtual bool  is_CFG() const { return (_con == TypeFunc::Control); }
   virtual uint ideal_reg() const;
--- a/hotspot/src/share/vm/opto/memnode.hpp	Thu Feb 28 15:40:09 2008 -0800
+++ b/hotspot/src/share/vm/opto/memnode.hpp	Fri Feb 29 09:57:18 2008 -0800
@@ -60,13 +60,13 @@
     debug_only(_adr_type=at; adr_type();)
   }
 
+public:
   // Helpers for the optimizer.  Documented in memnode.cpp.
   static bool detect_ptr_independence(Node* p1, AllocateNode* a1,
                                       Node* p2, AllocateNode* a2,
                                       PhaseTransform* phase);
   static bool adr_phi_is_loop_invariant(Node* adr_phi, Node* cast);
 
-public:
   // This one should probably be a phase-specific function:
   static bool detect_dominating_control(Node* dom, Node* sub);
 
--- a/hotspot/src/share/vm/opto/node.hpp	Thu Feb 28 15:40:09 2008 -0800
+++ b/hotspot/src/share/vm/opto/node.hpp	Fri Feb 29 09:57:18 2008 -0800
@@ -91,6 +91,7 @@
 class Node_Stack;
 class NullCheckNode;
 class OopMap;
+class ParmNode;
 class PCTableNode;
 class PhaseCCP;
 class PhaseGVN;
@@ -557,6 +558,7 @@
       DEFINE_CLASS_ID(JumpProj,  Proj, 1)
       DEFINE_CLASS_ID(IfTrue,    Proj, 2)
       DEFINE_CLASS_ID(IfFalse,   Proj, 3)
+      DEFINE_CLASS_ID(Parm,      Proj, 4)
 
     DEFINE_CLASS_ID(Region, Node, 3)
       DEFINE_CLASS_ID(Loop, Region, 0)
@@ -712,6 +714,7 @@
   DEFINE_CLASS_QUERY(Mul)
   DEFINE_CLASS_QUERY(Multi)
   DEFINE_CLASS_QUERY(MultiBranch)
+  DEFINE_CLASS_QUERY(Parm)
   DEFINE_CLASS_QUERY(PCTable)
   DEFINE_CLASS_QUERY(Phi)
   DEFINE_CLASS_QUERY(Proj)
--- a/hotspot/src/share/vm/opto/subnode.cpp	Thu Feb 28 15:40:09 2008 -0800
+++ b/hotspot/src/share/vm/opto/subnode.cpp	Fri Feb 29 09:57:18 2008 -0800
@@ -614,6 +614,13 @@
   const TypeOopPtr* p0 = r0->isa_oopptr();
   const TypeOopPtr* p1 = r1->isa_oopptr();
   if (p0 && p1) {
+    Node* in1 = in(1)->uncast();
+    Node* in2 = in(2)->uncast();
+    AllocateNode* alloc1 = AllocateNode::Ideal_allocation(in1, NULL);
+    AllocateNode* alloc2 = AllocateNode::Ideal_allocation(in2, NULL);
+    if (MemNode::detect_ptr_independence(in1, alloc1, in2, alloc2, NULL)) {
+      return TypeInt::CC_GT;  // different pointers
+    }
     ciKlass* klass0 = p0->klass();
     bool    xklass0 = p0->klass_is_exact();
     ciKlass* klass1 = p1->klass();