RFR: 8203339: Add oopDesc::field_offset()

Erik Österlund erik.osterlund at oracle.com
Thu May 17 08:19:49 UTC 2018


Hi Stefan,

Looks good.

Thanks,
/Erik

On 2018-05-17 09:23, Stefan Karlsson wrote:
> Hi all,
>
> Please review this patch to add a oopDesc::field_offset() convenience 
> function.
>
> http://cr.openjdk.java.net/~stefank/8203339/webrev.01/
> https://bugs.openjdk.java.net/browse/JDK-8203339
>
> We use it in ZGC to extract the offset to oop fields in some of our 
> OopClosures. The OopClosures provide the interior pointers to oop 
> fields, and together with the object pointer the offset can be 
> calculated.
>
> See the following ZGC use-case:
>
> http://hg.openjdk.java.net/zgc/zgc/file/3a52c8361e20/src/hotspot/share/gc/z/zHeapIterator.cpp#l87 
>
>
> class ZHeapIteratorPushOopClosure : public ExtendedOopClosure {
> private:
>   ZHeapIterator* const _iter;
>   const oop            _base;
>
> public:
>   ZHeapIteratorPushOopClosure(ZHeapIterator* iter, oop base) :
>       _iter(iter),
>       _base(base) {}
>
>   void do_oop_nv(oop* p) {
>     const oop obj = HeapAccess<ON_UNKNOWN_OOP_REF>::oop_load_at(_base, 
> _base->field_offset(p));
>     _iter->push(obj);
>   }
>
> Thanks,
> StefanK



More information about the hotspot-dev mailing list