Skip to content

Commit 1f32c11

Browse files
committed
8256740: ZGC: Move closures out of zOopClosure files
Reviewed-by: pliden
1 parent 659aec8 commit 1f32c11

14 files changed

+101
-175
lines changed

src/hotspot/share/gc/z/zBarrier.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "gc/z/zBarrier.inline.hpp"
2626
#include "gc/z/zHeap.inline.hpp"
2727
#include "gc/z/zOop.inline.hpp"
28-
#include "gc/z/zOopClosures.inline.hpp"
2928
#include "memory/iterator.inline.hpp"
3029
#include "oops/oop.inline.hpp"
3130
#include "runtime/safepoint.hpp"
@@ -239,3 +238,11 @@ oop ZBarrier::weak_load_barrier_on_phantom_oop_field_preloaded(volatile narrowOo
239238
ShouldNotReachHere();
240239
return NULL;
241240
}
241+
242+
void ZLoadBarrierOopClosure::do_oop(oop* p) {
243+
ZBarrier::load_barrier_on_oop_field(p);
244+
}
245+
246+
void ZLoadBarrierOopClosure::do_oop(narrowOop* p) {
247+
ShouldNotReachHere();
248+
}

src/hotspot/share/gc/z/zBarrier.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define SHARE_GC_Z_ZBARRIER_HPP
2626

2727
#include "memory/allocation.hpp"
28+
#include "memory/iterator.hpp"
2829
#include "oops/oop.hpp"
2930

3031
typedef bool (*ZBarrierFastPath)(uintptr_t);
@@ -122,4 +123,10 @@ class ZBarrier : public AllStatic {
122123
static oop weak_load_barrier_on_phantom_oop_field_preloaded(volatile narrowOop* p, oop o);
123124
};
124125

126+
class ZLoadBarrierOopClosure : public BasicOopIterateClosure {
127+
public:
128+
virtual void do_oop(oop* p);
129+
virtual void do_oop(narrowOop* p);
130+
};
131+
125132
#endif // SHARE_GC_Z_ZBARRIER_HPP

src/hotspot/share/gc/z/zBarrierSetNMethod.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "gc/z/zBarrierSetNMethod.hpp"
2727
#include "gc/z/zGlobals.hpp"
2828
#include "gc/z/zLock.inline.hpp"
29-
#include "gc/z/zOopClosures.hpp"
3029
#include "gc/z/zNMethod.hpp"
3130
#include "gc/z/zThreadLocalData.hpp"
3231
#include "logging/log.hpp"
@@ -53,9 +52,10 @@ bool ZBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
5352
return false;
5453
}
5554

56-
// Heal oops and disarm
57-
ZNMethodOopClosure cl;
58-
ZNMethod::nmethod_oops_do_inner(nm, &cl);
55+
// Heal oops
56+
ZNMethod::nmethod_oops_barrier(nm);
57+
58+
// Disarm
5959
disarm(nm);
6060

6161
return true;

src/hotspot/share/gc/z/zMark.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@
2222
*/
2323

2424
#include "precompiled.hpp"
25+
#include "classfile/classLoaderData.hpp"
2526
#include "classfile/classLoaderDataGraph.hpp"
2627
#include "code/nmethod.hpp"
2728
#include "gc/shared/suspendibleThreadSet.hpp"
2829
#include "gc/z/zBarrier.inline.hpp"
30+
#include "gc/z/zHeap.inline.hpp"
2931
#include "gc/z/zLock.inline.hpp"
3032
#include "gc/z/zMark.inline.hpp"
3133
#include "gc/z/zMarkCache.inline.hpp"
3234
#include "gc/z/zMarkStack.inline.hpp"
3335
#include "gc/z/zMarkTerminate.inline.hpp"
3436
#include "gc/z/zNMethod.hpp"
35-
#include "gc/z/zOopClosures.inline.hpp"
37+
#include "gc/z/zOop.inline.hpp"
3638
#include "gc/z/zPage.hpp"
3739
#include "gc/z/zPageTable.inline.hpp"
3840
#include "gc/z/zRootsIterator.hpp"
@@ -236,6 +238,26 @@ void ZMark::follow_partial_array(ZMarkStackEntry entry, bool finalizable) {
236238
follow_array(addr, size, finalizable);
237239
}
238240

241+
template <bool finalizable>
242+
class ZMarkBarrierOopClosure : public ClaimMetadataVisitingOopIterateClosure {
243+
public:
244+
ZMarkBarrierOopClosure() :
245+
ClaimMetadataVisitingOopIterateClosure(finalizable
246+
? ClassLoaderData::_claim_finalizable
247+
: ClassLoaderData::_claim_strong,
248+
finalizable
249+
? NULL
250+
: ZHeap::heap()->reference_discoverer()) {}
251+
252+
virtual void do_oop(oop* p) {
253+
ZBarrier::mark_barrier_on_oop_field(p, finalizable);
254+
}
255+
256+
virtual void do_oop(narrowOop* p) {
257+
ShouldNotReachHere();
258+
}
259+
};
260+
239261
void ZMark::follow_array_object(objArrayOop obj, bool finalizable) {
240262
if (finalizable) {
241263
ZMarkBarrierOopClosure<true /* finalizable */> cl;

src/hotspot/share/gc/z/zNMethod.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@
2828
#include "gc/shared/barrierSet.hpp"
2929
#include "gc/shared/barrierSetNMethod.hpp"
3030
#include "gc/shared/suspendibleThreadSet.hpp"
31+
#include "gc/z/zBarrier.inline.hpp"
3132
#include "gc/z/zGlobals.hpp"
3233
#include "gc/z/zLock.inline.hpp"
3334
#include "gc/z/zNMethod.hpp"
3435
#include "gc/z/zNMethodData.hpp"
3536
#include "gc/z/zNMethodTable.hpp"
36-
#include "gc/z/zOopClosures.inline.hpp"
3737
#include "gc/z/zTask.hpp"
3838
#include "gc/z/zWorkers.hpp"
3939
#include "logging/log.hpp"
4040
#include "memory/allocation.inline.hpp"
4141
#include "memory/iterator.hpp"
4242
#include "memory/resourceArea.hpp"
4343
#include "memory/universe.hpp"
44+
#include "oops/oop.inline.hpp"
4445
#include "runtime/atomic.hpp"
4546
#include "utilities/debug.hpp"
4647

@@ -243,6 +244,26 @@ void ZNMethod::nmethod_oops_do_inner(nmethod* nm, OopClosure* cl) {
243244
}
244245
}
245246

247+
class ZNMethodOopClosure : public OopClosure {
248+
public:
249+
virtual void do_oop(oop* p) {
250+
if (ZResurrection::is_blocked()) {
251+
ZBarrier::keep_alive_barrier_on_phantom_root_oop_field(p);
252+
} else {
253+
ZBarrier::load_barrier_on_root_oop_field(p);
254+
}
255+
}
256+
257+
virtual void do_oop(narrowOop* p) {
258+
ShouldNotReachHere();
259+
}
260+
};
261+
262+
void ZNMethod::nmethod_oops_barrier(nmethod* nm) {
263+
ZNMethodOopClosure cl;
264+
nmethod_oops_do_inner(nm, &cl);
265+
}
266+
246267
void ZNMethod::nmethods_do_begin() {
247268
ZNMethodTable::nmethods_do_begin();
248269
}
@@ -307,8 +328,7 @@ class ZNMethodUnlinkClosure : public NMethodClosure {
307328

308329
if (ZNMethod::is_armed(nm)) {
309330
// Heal oops and disarm
310-
ZNMethodOopClosure cl;
311-
ZNMethod::nmethod_oops_do(nm, &cl);
331+
ZNMethod::nmethod_oops_barrier(nm);
312332
ZNMethod::disarm(nm);
313333
}
314334

src/hotspot/share/gc/z/zNMethod.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class ZNMethod : public AllStatic {
5151
static void nmethod_oops_do(nmethod* nm, OopClosure* cl);
5252
static void nmethod_oops_do_inner(nmethod* nm, OopClosure* cl);
5353

54+
static void nmethod_oops_barrier(nmethod* nm);
55+
5456
static void nmethods_do_begin();
5557
static void nmethods_do_end();
5658
static void nmethods_do(NMethodClosure* cl);

src/hotspot/share/gc/z/zNMethodTable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "gc/z/zNMethodTable.hpp"
3535
#include "gc/z/zNMethodTableEntry.hpp"
3636
#include "gc/z/zNMethodTableIteration.hpp"
37-
#include "gc/z/zOopClosures.inline.hpp"
3837
#include "gc/z/zSafeDelete.inline.hpp"
3938
#include "gc/z/zTask.hpp"
4039
#include "gc/z/zWorkers.hpp"

src/hotspot/share/gc/z/zOopClosures.hpp

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/hotspot/share/gc/z/zOopClosures.inline.hpp

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/hotspot/share/gc/z/zReferenceProcessor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "gc/shared/referencePolicy.hpp"
2727
#include "gc/shared/referenceProcessorStats.hpp"
2828
#include "gc/z/zHeap.inline.hpp"
29-
#include "gc/z/zOopClosures.inline.hpp"
3029
#include "gc/z/zReferenceProcessor.hpp"
3130
#include "gc/z/zStat.hpp"
3231
#include "gc/z/zTask.hpp"

0 commit comments

Comments
 (0)