--- old/src/hotspot/share/code/nmethod.cpp 2018-09-28 16:47:31.656852300 +0200 +++ new/src/hotspot/share/code/nmethod.cpp 2018-09-28 16:47:31.514855560 +0200 @@ -2340,7 +2340,7 @@ for (int i = 0; i < oops_count(); i++) { oop o = oop_at(i); tty->print("#%3d: " INTPTR_FORMAT " ", i, p2i(o)); - if (o == (oop)Universe::non_oop_word()) { + if (o == Universe::non_oop_word()) { tty->print("non-oop word"); } else { if (o != NULL) { --- old/src/hotspot/share/code/relocInfo.cpp 2018-09-28 16:47:32.072842749 +0200 +++ new/src/hotspot/share/code/relocInfo.cpp 2018-09-28 16:47:31.932845963 +0200 @@ -574,7 +574,7 @@ oop oop_Relocation::oop_value() { oop v = *oop_addr(); // clean inline caches store a special pseudo-null - if (v == (oop)Universe::non_oop_word()) v = NULL; + if (v == Universe::non_oop_word()) v = NULL; return v; } --- old/src/hotspot/share/compiler/oopMap.cpp 2018-09-28 16:47:32.466833704 +0200 +++ new/src/hotspot/share/compiler/oopMap.cpp 2018-09-28 16:47:32.328836872 +0200 @@ -350,7 +350,7 @@ // implicit null check is used in compiled code. // The narrow_oop_base could be NULL or be the address // of the page below heap depending on compressed oops mode. - if (base_loc != NULL && *base_loc != (oop)NULL && !Universe::is_narrow_oop_base(*base_loc)) { + if (base_loc != NULL && *base_loc != NULL && !Universe::is_narrow_oop_base(*base_loc)) { derived_oop_fn(base_loc, derived_loc); } oms.next(); @@ -371,7 +371,7 @@ guarantee(loc != NULL, "missing saved register"); if ( omv.type() == OopMapValue::oop_value ) { oop val = *loc; - if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) { + if (val == NULL || Universe::is_narrow_oop_base(val)) { // Ignore NULL oops and decoded NULL narrow oops which // equal to Universe::narrow_oop_base when a narrow oop // implicit null check is used in compiled code. @@ -769,7 +769,7 @@ assert(Universe::heap()->is_in_or_null(*base_loc), "not an oop"); assert(derived_loc != base_loc, "Base and derived in same location"); if (_active) { - assert(*derived_loc != (oop)base_loc, "location already added"); + assert(*derived_loc != (void*)base_loc, "location already added"); assert(_list != NULL, "list must exist"); intptr_t offset = value_of_loc(derived_loc) - value_of_loc(base_loc); // This assert is invalid because derived pointers can be --- old/src/hotspot/share/gc/shared/gc_globals.hpp 2018-09-28 16:47:32.873824360 +0200 +++ new/src/hotspot/share/gc/shared/gc_globals.hpp 2018-09-28 16:47:32.732827597 +0200 @@ -822,6 +822,10 @@ product(uintx, GCDrainStackTargetSize, 64, \ "Number of entries we will try to leave on the stack " \ "during parallel gc") \ - range(0, max_juint) + range(0, max_juint) \ + \ + develop(bool, VerifyObjectEquals, false, \ + "Verify that == and != are not used on oops. Only in fastdebug") \ + #endif // SHARE_GC_SHARED_GC_GLOBALS_HPP --- old/src/hotspot/share/gc/shared/referenceProcessor.cpp 2018-09-28 16:47:33.274815153 +0200 +++ new/src/hotspot/share/gc/shared/referenceProcessor.cpp 2018-09-28 16:47:33.132818413 +0200 @@ -284,7 +284,7 @@ // First _prev_next ref actually points into DiscoveredList (gross). oop new_next; - if (_next_discovered == _current_discovered) { + if (oopDesc::unsafe_equals(_next_discovered, _current_discovered)) { // At the end of the list, we should make _prev point to itself. // If _ref is the first ref, then _prev_next will be in the DiscoveredList, // and _prev will be NULL. @@ -474,7 +474,7 @@ ReferenceProcessor::clear_discovered_references(DiscoveredList& refs_list) { oop obj = NULL; oop next = refs_list.head(); - while (next != obj) { + while (! oopDesc::unsafe_equals(next, obj)) { obj = next; next = java_lang_ref_Reference::discovered(obj); java_lang_ref_Reference::set_discovered_raw(obj, NULL); @@ -746,7 +746,7 @@ ref_lists[to_idx].inc_length(refs_to_move); // Remove the chain from the from list. - if (move_tail == new_head) { + if (oopDesc::unsafe_equals(move_tail, new_head)) { // We found the end of the from list. ref_lists[from_idx].set_head(NULL); } else { --- old/src/hotspot/share/gc/shared/referenceProcessor.hpp 2018-09-28 16:47:33.676805924 +0200 +++ new/src/hotspot/share/gc/shared/referenceProcessor.hpp 2018-09-28 16:47:33.535809161 +0200 @@ -143,13 +143,13 @@ inline size_t removed() const { return _removed; } inline void move_to_next() { - if (_current_discovered == _next_discovered) { + if (oopDesc::unsafe_equals(_current_discovered, _next_discovered)) { // End of the list. _current_discovered = NULL; } else { _current_discovered = _next_discovered; } - assert(_current_discovered != _first_seen, "cyclic ref_list found"); + assert(! oopDesc::unsafe_equals(_current_discovered, _first_seen), "cyclic ref_list found"); _processed++; } }; --- old/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp 2018-09-28 16:47:34.069796901 +0200 +++ new/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp 2018-09-28 16:47:33.929800115 +0200 @@ -375,7 +375,7 @@ } typeArrayOop existing_value = lookup_or_add(value, latin1, hash); - if (existing_value == value) { + if (oopDesc::unsafe_equals(existing_value, value)) { // Same value, already known stat->inc_known(); return; --- old/src/hotspot/share/oops/accessBackend.hpp 2018-09-28 16:47:34.475787580 +0200 +++ new/src/hotspot/share/oops/accessBackend.hpp 2018-09-28 16:47:34.332790863 +0200 @@ -410,7 +410,7 @@ static oop resolve(oop obj) { return obj; } - static bool equals(oop o1, oop o2) { return o1 == o2; } + static bool equals(oop o1, oop o2) { return (void*) o1 == (void*) o2; } }; // Below is the implementation of the first 4 steps of the template pipeline: --- old/src/hotspot/share/oops/oop.hpp 2018-09-28 16:47:34.875778397 +0200 +++ new/src/hotspot/share/oops/oop.hpp 2018-09-28 16:47:34.734781634 +0200 @@ -154,6 +154,10 @@ inline static bool equals(oop o1, oop o2) { return Access<>::equals(o1, o2); } + inline static bool unsafe_equals(oop o1, oop o2) { + return (void*) o1 == (void*) o2; + } + // Access to fields in a instanceOop through these methods. template oop obj_field_access(int offset) const; --- old/src/hotspot/share/oops/oopsHierarchy.hpp 2018-09-28 16:47:35.273769259 +0200 +++ new/src/hotspot/share/oops/oopsHierarchy.hpp 2018-09-28 16:47:35.133772474 +0200 @@ -101,9 +101,15 @@ // General access oopDesc* operator->() const { return obj(); } - bool operator==(const oop o) const { return obj() == o.obj(); } + bool operator==(const oop o) const { + assert(!VerifyObjectEquals, "Missing oopDesc::equals(..)"); + return obj() == o.obj(); + } bool operator==(void *p) const { return obj() == p; } - bool operator!=(const volatile oop o) const { return obj() != o.obj(); } + bool operator!=(const volatile oop o) const { + assert(!VerifyObjectEquals, "Missing !oopDesc::equals(..)"); + return obj() != o.obj(); + } bool operator!=(void *p) const { return obj() != p; } // Assignment