Skip to content

Commit

Permalink
8242216: ObjectSampler::weak_oops_do() should not trigger barrier
Browse files Browse the repository at this point in the history
Reviewed-by: rkennke, eosterlund
  • Loading branch information
zhengyu123 committed Apr 7, 2020
1 parent 1a40b79 commit e53ae5a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/hotspot/share/jfr/leakprofiler/sampling/objectSample.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,6 +29,10 @@ const oop ObjectSample::object() const {
return NativeAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(&_object);
}

const oop ObjectSample::object_raw() const {
return RawAccess<>::oop_load(&_object);
}

void ObjectSample::set_object(oop object) {
NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(&_object, object);
}
3 changes: 2 additions & 1 deletion src/hotspot/share/jfr/leakprofiler/sampling/objectSample.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -108,6 +108,7 @@ class ObjectSample : public JfrCHeapObj {
}

const oop object() const;
const oop object_raw() const;
void set_object(oop object);

const oop* object_addr() const {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -223,7 +223,7 @@ void ObjectSampler::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) {
ObjectSample* current = sampler._list->last();
while (current != NULL) {
if (current->_object != NULL) {
if (is_alive->do_object_b(current->object())) {
if (is_alive->do_object_b(current->object_raw())) {
// The weakly referenced object is alive, update pointer
f->do_oop(const_cast<oop*>(current->object_addr()));
} else {
Expand Down

0 comments on commit e53ae5a

Please sign in to comment.