diff --git a/src/hotspot/share/oops/accessBackend.hpp b/src/hotspot/share/oops/accessBackend.hpp index abcf59a..fefc872 100644 --- a/src/hotspot/share/oops/accessBackend.hpp +++ b/src/hotspot/share/oops/accessBackend.hpp @@ -1293,6 +1293,82 @@ namespace AccessInternal { const DecoratorSet expanded_decorators = DecoratorFixup::value; return PreRuntimeDispatch::equals(o1, o2); } + + // Infer the type that should be returned from an Access::oop_load. + template + class OopLoadProxy: public StackObj { + private: + P *const _addr; + public: + OopLoadProxy(P* addr) : _addr(addr) {} + + inline operator oop() { + 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; + } + }; + + // Infer the type that should be returned from an Access::load_at. + template + class LoadAtProxy: public StackObj { + private: + const oop _base; + const ptrdiff_t _offset; + public: + LoadAtProxy(oop base, ptrdiff_t offset) : _base(base), _offset(offset) {} + + template + 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; } + }; + + // Infer the type that should be returned from an Access::oop_load_at. + 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; + } + }; } #endif // SHARE_OOPS_ACCESSBACKEND_HPP