Scalar replacable object pointers won't be equal to anything else
Edward Lee
edilee at gmail.com
Tue Dec 9 10:52:39 PST 2008
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.)
Ed
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stack.cmpp.txt
Url: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20081209/f54155df/attachment.txt
More information about the hotspot-dev
mailing list