Skip to content
Permalink
Browse files
8133873: Simplify {Register,Unregister}NMethodOopClosure
Reviewed-by: tschatzl, kbarrett
  • Loading branch information
albertnetymk committed Jul 1, 2021
1 parent 06d2620 commit 54a9c3e39fedf7eb0277c602c3767af654371c47
Showing 1 changed file with 14 additions and 16 deletions.
@@ -4204,8 +4204,12 @@ class RegisterNMethodOopClosure: public OopClosure {
G1CollectedHeap* _g1h;
nmethod* _nm;

template <class T> void do_oop_work(T* p) {
T heap_oop = RawAccess<>::oop_load(p);
public:
RegisterNMethodOopClosure(G1CollectedHeap* g1h, nmethod* nm) :
_g1h(g1h), _nm(nm) {}

void do_oop(oop* p) {
oop heap_oop = RawAccess<>::oop_load(p);
if (!CompressedOops::is_null(heap_oop)) {
oop obj = CompressedOops::decode_not_null(heap_oop);
HeapRegion* hr = _g1h->heap_region_containing(obj);
@@ -4219,20 +4223,19 @@ class RegisterNMethodOopClosure: public OopClosure {
}
}

public:
RegisterNMethodOopClosure(G1CollectedHeap* g1h, nmethod* nm) :
_g1h(g1h), _nm(nm) {}

void do_oop(oop* p) { do_oop_work(p); }
void do_oop(narrowOop* p) { do_oop_work(p); }
void do_oop(narrowOop* p) { ShouldNotReachHere(); }
};

class UnregisterNMethodOopClosure: public OopClosure {
G1CollectedHeap* _g1h;
nmethod* _nm;

template <class T> void do_oop_work(T* p) {
T heap_oop = RawAccess<>::oop_load(p);
public:
UnregisterNMethodOopClosure(G1CollectedHeap* g1h, nmethod* nm) :
_g1h(g1h), _nm(nm) {}

void do_oop(oop* p) {
oop heap_oop = RawAccess<>::oop_load(p);
if (!CompressedOops::is_null(heap_oop)) {
oop obj = CompressedOops::decode_not_null(heap_oop);
HeapRegion* hr = _g1h->heap_region_containing(obj);
@@ -4245,12 +4248,7 @@ class UnregisterNMethodOopClosure: public OopClosure {
}
}

public:
UnregisterNMethodOopClosure(G1CollectedHeap* g1h, nmethod* nm) :
_g1h(g1h), _nm(nm) {}

void do_oop(oop* p) { do_oop_work(p); }
void do_oop(narrowOop* p) { do_oop_work(p); }
void do_oop(narrowOop* p) { ShouldNotReachHere(); }
};

void G1CollectedHeap::register_nmethod(nmethod* nm) {

1 comment on commit 54a9c3e

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 54a9c3e Jul 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.