Scalar replacable object pointers won't be equal to anything else
Vladimir Kozlov
Vladimir.Kozlov at Sun.COM
Tue Dec 9 15:30:06 PST 2008
I see. And this is correct since in general case we don't
know if the pointer to the allocation is stored into list.key field.
It would be nice if we can eliminate CmpP early.
With EA we have the knowledge about all references to
allocations. Could you try the next change in detect_ptr_independence()?:
diff -r 7a018855d2f0 src/share/vm/opto/memnode.cpp
--- a/src/share/vm/opto/memnode.cpp Mon Dec 08 17:15:02 2008 -0800
+++ b/src/share/vm/opto/memnode.cpp Tue Dec 09 15:25:29 2008 -0800
@@ -379,9 +379,29 @@ bool MemNode::detect_ptr_independence(No
} else if (a1 != NULL && a2 != NULL) { // both allocations
return (a1 != a2);
} else if (a1 != NULL) { // one allocation a1
+ if (EliminateAllocations && a1->_is_scalar_replaceable) {
+ ConnectionGraph *cgr = phase->C->congraph();
+ PointsToNode::EscapeState es = PointsToNode::GlobalEscape;
+ if (cgr != NULL)
+ es = cgr->escape_state(p2, phase);
+ if (es == PointsToNode::GlobalEscape) {
+ return true; // different escape status
+ }
+ }
+ }
// (Note: p2->is_Con implies p2->in(0)->is_Root, which dominates.)
return all_controls_dominate(p2, a1);
} else { //(a2 != NULL) // one allocation a2
+ if (EliminateAllocations && a2->_is_scalar_replaceable) {
+ ConnectionGraph *cgr = phase->C->congraph();
+ PointsToNode::EscapeState es = PointsToNode::GlobalEscape;
+ if (cgr != NULL)
+ es = cgr->escape_state(p1, phase);
+ if (es == PointsToNode::GlobalEscape) {
+ return true; // different escape status
+ }
+ }
+ }
return all_controls_dominate(p1, a2);
}
return false;
Thanks,
Vladimir
Edward Lee wrote:
> When expanding HashMap.get(new Packed(v1, v2)), it looks something like..
>
> tmp = new Packed(v1, v2)
> for (e = table[tmp.hashCode()]; e != null; e = e.next)
> if (e.key == tmp) return e.value
>
> On Tue, Dec 9, 2008 at 2:21 PM, Vladimir Kozlov <Vladimir.Kozlov at sun.com> wrote:
>> There is code in CmpPNode::sub() to optimize CmpP for
>> allocations. Why it does not work for your case?
>
> For this particular CmpPNode::sub() call, it uses
> MemNode::detect_ptr_independence() that eventually calls
> MemNode::all_controls_dominate() where the dom node is the LoadP for
> list.key and sub node is the tmp Allocate.
>
> The LoadP is inside the loop, so the Allocate node isn't dominated by
> all of the LoadP's loop control.
>
> Ed
More information about the hotspot-dev
mailing list