Scalar replacable object pointers won't be equal to anything else
Vladimir.Kozlov at Sun.COM
Tue Dec 9 12:21:01 PST 2008
There is code in CmpPNode::sub() to optimize CmpP for
allocations. Why it does not work for your case?
Edward Lee wrote:
> I've been running into several instances of HashMap.get(new Packed(v1,
> v2)) used to retrieve items that have Keys with custom equals()
> methods. Part of HashMap.get() checks if the entry's key is == equal
> to the argument key before using equals(). This behavior prevents
> inlined NoEscape objects from having its allocation removed, so when
> the newly allocated object's field accesses are optimized to earlier
> memory references, the only use of the object is a pointer comparison
> that will always be false.
> Attached is a quick patch that converts potentially scalar replacable
> object's CmpP use into a not-equal value, so that optimizations down
> the way will get rid of the dependent branch as well as remove the
> allocation entirely.
> (Just to make sure, any local allocation should have AddP.Identify()
> calls point to the same allocation, so if there /is/ a situation where
> CmpP is given the same local allocation, it'll simplify to an EQ
> comparison node. Additionally, escape analysis would make sure that
> allocations passed to other methods wouldn't show up as NoEscape.)
More information about the hotspot-dev