Skip to content
Permalink
Browse files
8266426: ZHeapIteratorOopClosure does not handle native access properly
Co-authored-by: Per Liden <pliden@openjdk.org>
Co-authored-by: Erik Österlund <eosterlund@openjdk.org>
Co-authored-by: Stefan Karlsson <stefank@openjdk.org>
Reviewed-by: stefank, pliden
  • Loading branch information
4 people committed May 6, 2021
1 parent 2438498 commit 47d4438e75eca6f6f2aef9c0f88cab78996f7f80
Showing with 38 additions and 2 deletions.
  1. +38 −2 src/hotspot/share/gc/z/zHeapIterator.cpp
@@ -27,6 +27,7 @@
#include "gc/shared/gc_globals.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zCollectedHeap.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zGranuleMap.inline.hpp"
#include "gc/z/zHeapIterator.hpp"
@@ -123,12 +124,14 @@ class ZHeapIteratorRootOopClosure : public OopClosure {
};

template <bool VisitReferents>
class ZHeapIteratorOopClosure : public ClaimMetadataVisitingOopIterateClosure {
class ZHeapIteratorOopClosure : public OopIterateClosure {
private:
const ZHeapIteratorContext& _context;
const oop _base;

oop load_oop(oop* p) {
assert(ZCollectedHeap::heap()->is_in(p), "Should be in heap");

if (VisitReferents) {
return HeapAccess<AS_NO_KEEPALIVE | ON_UNKNOWN_OOP_REF>::oop_load_at(_base, _base->field_offset(p));
}
@@ -138,7 +141,7 @@ class ZHeapIteratorOopClosure : public ClaimMetadataVisitingOopIterateClosure {

public:
ZHeapIteratorOopClosure(const ZHeapIteratorContext& context, oop base) :
ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_other),
OopIterateClosure(),
_context(context),
_base(base) {}

@@ -154,6 +157,39 @@ class ZHeapIteratorOopClosure : public ClaimMetadataVisitingOopIterateClosure {
virtual void do_oop(narrowOop* p) {
ShouldNotReachHere();
}

virtual bool do_metadata() {
return true;
}

virtual void do_klass(Klass* k) {
ClassLoaderData* const cld = k->class_loader_data();
ZHeapIteratorOopClosure::do_cld(cld);
}

virtual void do_cld(ClassLoaderData* cld) {
class NativeAccessClosure : public OopClosure {
private:
const ZHeapIteratorContext& _context;

public:
explicit NativeAccessClosure(const ZHeapIteratorContext& context) :
_context(context) {}

virtual void do_oop(oop* p) {
assert(!ZCollectedHeap::heap()->is_in(p), "Should not be in heap");
const oop obj = NativeAccess<AS_NO_KEEPALIVE>::oop_load(p);
_context.mark_and_push(obj);
}

virtual void do_oop(narrowOop* p) {
ShouldNotReachHere();
}
};

NativeAccessClosure cl(_context);
cld->oops_do(&cl, ClassLoaderData::_claim_other);
}
};

ZHeapIterator::ZHeapIterator(uint nworkers, bool visit_weaks) :

1 comment on commit 47d4438

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 47d4438 May 6, 2021

Please sign in to comment.