diff --git a/src/hotspot/share/oops/access.hpp b/src/hotspot/share/oops/access.hpp index 95410e0bba3..0337d2a9dfa 100644 --- a/src/hotspot/share/oops/access.hpp +++ b/src/hotspot/share/oops/access.hpp @@ -306,19 +306,28 @@ namespace AccessInternal { // Infer the type that should be returned from a load. template - class LoadProxy: public StackObj { + class OopLoadProxy: public StackObj { private: P *const _addr; public: - LoadProxy(P* addr) : _addr(addr) {} + OopLoadProxy(P* addr) : _addr(addr) {} - template - inline operator T() { - return load(_addr); + inline operator oop() { + return load(_addr); } - inline operator P() { - return load(_addr); + inline operator narrowOop() { + return load(_addr); + } + + template + inline bool operator ==(const T& other) const { + return load(_addr) == other; + } + + template + inline bool operator !=(const T& other) const { + return load(_addr) != other; } }; @@ -335,6 +344,39 @@ namespace AccessInternal { inline operator T() const { return load_at(_base, _offset); } + + template + inline bool operator ==(const T& other) const { return load_at(_base, _offset) == other; } + + template + inline bool operator !=(const T& other) const { return load_at(_base, _offset) != other; } + }; + + template + class OopLoadAtProxy: public StackObj { + private: + const oop _base; + const ptrdiff_t _offset; + public: + OopLoadAtProxy(oop base, ptrdiff_t offset) : _base(base), _offset(offset) {} + + inline operator oop() const { + return load_at(_base, _offset); + } + + inline operator narrowOop() const { + return load_at(_base, _offset); + } + + template + inline bool operator ==(const T& other) const { + return load_at(_base, _offset) == other; + } + + template + inline bool operator !=(const T& other) const { + return load_at(_base, _offset) != other; + } }; } @@ -409,9 +451,9 @@ public: } // Oop heap accesses - static inline AccessInternal::LoadAtProxy oop_load_at(oop base, ptrdiff_t offset) { + static inline AccessInternal::OopLoadAtProxy oop_load_at(oop base, ptrdiff_t offset) { verify_heap_oop_decorators(); - return AccessInternal::LoadAtProxy(base, offset); + return AccessInternal::OopLoadAtProxy(base, offset); } template @@ -478,9 +520,9 @@ public: // Oop accesses template - static inline AccessInternal::LoadProxy oop_load(P* addr) { + static inline AccessInternal::OopLoadProxy oop_load(P* addr) { verify_oop_decorators(); - return AccessInternal::LoadProxy(addr); + return AccessInternal::OopLoadProxy(addr); } template