From b72fe8e157a620780926dde3e31b41f79d126f24 Mon Sep 17 00:00:00 2001 From: kvn Date: Fri, 29 Feb 2008 09:57:18 -0800 Subject: [PATCH] 6667580: Optimize CmpP for allocations Summary: CmpP could be optimized out if it compares new allocated objects. Reviewed-by: jrose, never, rasbold --- src/share/vm/includeDB_compiler2 | 7 ++++--- src/share/vm/opto/callnode.hpp | 6 ++++-- src/share/vm/opto/memnode.hpp | 2 +- src/share/vm/opto/node.hpp | 3 +++ src/share/vm/opto/subnode.cpp | 7 +++++++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/share/vm/includeDB_compiler2 b/src/share/vm/includeDB_compiler2 index 0138cc664..01a6b9c94 100644 --- a/src/share/vm/includeDB_compiler2 +++ b/src/share/vm/includeDB_compiler2 @@ -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_.cpp adGlobals_.hpp @@ -990,6 +990,7 @@ stubRoutines.cpp runtime.hpp 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 growableArray.hpp 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 @@ parse2.cpp idealGraphPrinter.hpp parse1.cpp idealGraphPrinter.hpp matcher.cpp idealGraphPrinter.hpp loopnode.cpp idealGraphPrinter.hpp -chaitin.cpp idealGraphPrinter.hpp +chaitin.cpp idealGraphPrinter.hpp diff --git a/src/share/vm/opto/callnode.hpp b/src/share/vm/opto/callnode.hpp index e1e6116b6..c8315f94c 100644 --- a/src/share/vm/opto/callnode.hpp +++ b/src/share/vm/opto/callnode.hpp @@ -38,7 +38,7 @@ class CallRuntimeNode; class CallLeafNode; class CallLeafNoFPNode; class AllocateNode; -class AllocateArrayNode; +class AllocateArrayNode; class LockNode; class UnlockNode; class JVMState; @@ -91,7 +91,9 @@ public: 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; diff --git a/src/share/vm/opto/memnode.hpp b/src/share/vm/opto/memnode.hpp index 505cbdf97..8c8676b4d 100644 --- a/src/share/vm/opto/memnode.hpp +++ b/src/share/vm/opto/memnode.hpp @@ -60,13 +60,13 @@ protected: 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); diff --git a/src/share/vm/opto/node.hpp b/src/share/vm/opto/node.hpp index f93562c09..8066da703 100644 --- a/src/share/vm/opto/node.hpp +++ b/src/share/vm/opto/node.hpp @@ -91,6 +91,7 @@ class Node_List; class Node_Stack; class NullCheckNode; class OopMap; +class ParmNode; class PCTableNode; class PhaseCCP; class PhaseGVN; @@ -557,6 +558,7 @@ public: 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 @@ public: 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) diff --git a/src/share/vm/opto/subnode.cpp b/src/share/vm/opto/subnode.cpp index 1344197ca..2fc002892 100644 --- a/src/share/vm/opto/subnode.cpp +++ b/src/share/vm/opto/subnode.cpp @@ -614,6 +614,13 @@ const Type *CmpPNode::sub( const Type *t1, const Type *t2 ) const { 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(); -- GitLab