RFR: JDK-8199781: Don't use naked == for comparing oops

Roman Kennke rkennke at redhat.com
Mon Mar 19 18:32:19 UTC 2018


GCs might need to handle object comparison specially, for example, when
a concurrent GC allows both from- and to-space copies of an object to be
in use. In this case, object equality cannot be expressed by direct
address comparsion, but must also take potential different versions of
an object into account.

This adds a method oopDesc::equals(oop o1, oop o2), which goes through
the Access API to compare objects. Default impl does ==

It is based on our finds from Shenandoah. We do, in fact, have some
extra code in oopsHierarchy.hpp to detect naked oop==oop (with
CheckUnhandledOops enabled), but it requires that code that does really
want naked == (e.g. GCs) to use another method oopDesc::unsafe_equals()
instead, and code that wants to use == and assert that the comparison is
safe (e.g. both objects are already in to-space) use
oopDesc::safe_equals(). Not sure if you want that?

Also, I'd have preferred to mark equals() as inline in oop.hpp, but that
pulls in a rats nest of dependencies problems. I hope the way I did it
is acceptable?

There's one little thing in growableArray.hpp: in order to do the right
thing for GrowableArray<oop> I needed to provide a special templated
comparison function, with a specialized version for oop.

It also overloads the == operator in Handle to do the right thing.

Webrev:
http://cr.openjdk.java.net/~rkennke/JDK-8199781/webrev.00/

Testing: built fastdebug/release, tier1_runtime, tier1_gc

Please review!

Thanks, Roman



More information about the hotspot-runtime-dev mailing list