8031401: Remove unused code in the reference processor
Assume pending_list uses discovered field and remove resulting dead code. Reviewed-by: brutisso, pliden
This commit is contained in:
parent
7d01ef4a6e
commit
878cf5e641
@ -257,31 +257,18 @@ static void oop_pc_follow_contents_specialized(InstanceRefKlass* klass, oop obj,
|
||||
}
|
||||
}
|
||||
T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
|
||||
if (ReferenceProcessor::pending_list_uses_discovered_field()) {
|
||||
// Treat discovered as normal oop, if ref is not "active",
|
||||
// i.e. if next is non-NULL.
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
|
||||
T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
|
||||
debug_only(
|
||||
if(TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" Process discovered as normal "
|
||||
PTR_FORMAT, p2i(discovered_addr));
|
||||
}
|
||||
)
|
||||
cm->mark_and_push(discovered_addr);
|
||||
}
|
||||
} else {
|
||||
#ifdef ASSERT
|
||||
// In the case of older JDKs which do not use the discovered
|
||||
// field for the pending list, an inactive ref (next != NULL)
|
||||
// must always have a NULL discovered field.
|
||||
T next = oopDesc::load_heap_oop(next_addr);
|
||||
oop discovered = java_lang_ref_Reference::discovered(obj);
|
||||
assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
|
||||
err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
|
||||
p2i(obj)));
|
||||
#endif
|
||||
// Treat discovered as normal oop, if ref is not "active",
|
||||
// i.e. if next is non-NULL.
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
|
||||
T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
|
||||
debug_only(
|
||||
if(TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" Process discovered as normal "
|
||||
PTR_FORMAT, p2i(discovered_addr));
|
||||
}
|
||||
)
|
||||
cm->mark_and_push(discovered_addr);
|
||||
}
|
||||
cm->mark_and_push(next_addr);
|
||||
klass->InstanceKlass::oop_pc_follow_contents(obj, cm);
|
||||
|
@ -365,33 +365,19 @@ static void oop_ps_push_contents_specialized(oop obj, InstanceRefKlass *klass, P
|
||||
// Treat discovered as normal oop, if ref is not "active",
|
||||
// i.e. if next is non-NULL.
|
||||
T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
|
||||
if (ReferenceProcessor::pending_list_uses_discovered_field()) {
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
|
||||
T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
|
||||
debug_only(
|
||||
if(TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" Process discovered as normal "
|
||||
PTR_FORMAT, p2i(discovered_addr));
|
||||
}
|
||||
)
|
||||
if (PSScavenge::should_scavenge(discovered_addr)) {
|
||||
pm->claim_or_forward_depth(discovered_addr);
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
|
||||
T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
|
||||
debug_only(
|
||||
if(TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" Process discovered as normal "
|
||||
PTR_FORMAT, p2i(discovered_addr));
|
||||
}
|
||||
)
|
||||
if (PSScavenge::should_scavenge(discovered_addr)) {
|
||||
pm->claim_or_forward_depth(discovered_addr);
|
||||
}
|
||||
} else {
|
||||
#ifdef ASSERT
|
||||
// In the case of older JDKs which do not use the discovered
|
||||
// field for the pending list, an inactive ref (next != NULL)
|
||||
// must always have a NULL discovered field.
|
||||
oop next = oopDesc::load_decode_heap_oop(next_addr);
|
||||
oop discovered = java_lang_ref_Reference::discovered(obj);
|
||||
assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
|
||||
err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
|
||||
p2i(obj)));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Treat next as normal oop; next is a link in the reference queue.
|
||||
if (PSScavenge::should_scavenge(next_addr)) {
|
||||
pm->claim_or_forward_depth(next_addr);
|
||||
|
@ -145,31 +145,18 @@ static void oop_ms_follow_contents_specialized(InstanceRefKlass* klass, oop obj)
|
||||
}
|
||||
}
|
||||
T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
|
||||
if (ReferenceProcessor::pending_list_uses_discovered_field()) {
|
||||
// Treat discovered as normal oop, if ref is not "active",
|
||||
// i.e. if next is non-NULL.
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
|
||||
T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
|
||||
debug_only(
|
||||
if(TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" Process discovered as normal "
|
||||
PTR_FORMAT, p2i(discovered_addr));
|
||||
}
|
||||
)
|
||||
MarkSweep::mark_and_push(discovered_addr);
|
||||
}
|
||||
} else {
|
||||
#ifdef ASSERT
|
||||
// In the case of older JDKs which do not use the discovered
|
||||
// field for the pending list, an inactive ref (next != NULL)
|
||||
// must always have a NULL discovered field.
|
||||
oop next = oopDesc::load_decode_heap_oop(next_addr);
|
||||
oop discovered = java_lang_ref_Reference::discovered(obj);
|
||||
assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
|
||||
err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
|
||||
p2i(obj)));
|
||||
#endif
|
||||
// Treat discovered as normal oop, if ref is not "active",
|
||||
// i.e. if next is non-NULL.
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
|
||||
T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
|
||||
debug_only(
|
||||
if(TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" Process discovered as normal "
|
||||
PTR_FORMAT, p2i(discovered_addr));
|
||||
}
|
||||
)
|
||||
MarkSweep::mark_and_push(discovered_addr);
|
||||
}
|
||||
// treat next as normal oop. next is a link in the reference queue.
|
||||
debug_only(
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
|
||||
ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL;
|
||||
bool ReferenceProcessor::_pending_list_uses_discovered_field = false;
|
||||
jlong ReferenceProcessor::_soft_ref_timestamp_clock = 0;
|
||||
|
||||
void referenceProcessor_init() {
|
||||
@ -63,7 +62,6 @@ void ReferenceProcessor::init_statics() {
|
||||
guarantee(RefDiscoveryPolicy == ReferenceBasedDiscovery ||
|
||||
RefDiscoveryPolicy == ReferentBasedDiscovery,
|
||||
"Unrecognized RefDiscoveryPolicy");
|
||||
_pending_list_uses_discovered_field = JDK_Version::current().pending_list_uses_discovered_field();
|
||||
}
|
||||
|
||||
void ReferenceProcessor::enable_discovery(bool check_no_refs) {
|
||||
@ -353,10 +351,6 @@ void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list,
|
||||
// all linked Reference objects. Note that it is important to not dirty any
|
||||
// cards during reference processing since this will cause card table
|
||||
// verification to fail for G1.
|
||||
//
|
||||
// BKWRD COMPATIBILITY NOTE: For older JDKs (prior to the fix for 4956777),
|
||||
// the "next" field is used to chain the pending list, not the discovered
|
||||
// field.
|
||||
if (TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr("ReferenceProcessor::enqueue_discovered_reflist list "
|
||||
INTPTR_FORMAT, p2i(refs_list.head()));
|
||||
@ -364,64 +358,30 @@ void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list,
|
||||
|
||||
oop obj = NULL;
|
||||
oop next_d = refs_list.head();
|
||||
if (pending_list_uses_discovered_field()) { // New behavior
|
||||
// Walk down the list, self-looping the next field
|
||||
// so that the References are not considered active.
|
||||
while (obj != next_d) {
|
||||
obj = next_d;
|
||||
assert(obj->is_instanceRef(), "should be reference object");
|
||||
next_d = java_lang_ref_Reference::discovered(obj);
|
||||
if (TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT,
|
||||
p2i(obj), p2i(next_d));
|
||||
}
|
||||
assert(java_lang_ref_Reference::next(obj) == NULL,
|
||||
"Reference not active; should not be discovered");
|
||||
// Self-loop next, so as to make Ref not active.
|
||||
java_lang_ref_Reference::set_next_raw(obj, obj);
|
||||
if (next_d != obj) {
|
||||
oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), next_d);
|
||||
} else {
|
||||
// This is the last object.
|
||||
// Swap refs_list into pending_list_addr and
|
||||
// set obj's discovered to what we read from pending_list_addr.
|
||||
oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr);
|
||||
// Need post-barrier on pending_list_addr. See enqueue_discovered_ref_helper() above.
|
||||
java_lang_ref_Reference::set_discovered_raw(obj, old); // old may be NULL
|
||||
oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), old);
|
||||
}
|
||||
// Walk down the list, self-looping the next field
|
||||
// so that the References are not considered active.
|
||||
while (obj != next_d) {
|
||||
obj = next_d;
|
||||
assert(obj->is_instanceRef(), "should be reference object");
|
||||
next_d = java_lang_ref_Reference::discovered(obj);
|
||||
if (TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT,
|
||||
p2i(obj), p2i(next_d));
|
||||
}
|
||||
} else { // Old behavior
|
||||
// Walk down the list, copying the discovered field into
|
||||
// the next field and clearing the discovered field.
|
||||
while (obj != next_d) {
|
||||
obj = next_d;
|
||||
assert(obj->is_instanceRef(), "should be reference object");
|
||||
next_d = java_lang_ref_Reference::discovered(obj);
|
||||
if (TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT,
|
||||
p2i(obj), p2i(next_d));
|
||||
}
|
||||
assert(java_lang_ref_Reference::next(obj) == NULL,
|
||||
"The reference should not be enqueued");
|
||||
if (next_d == obj) { // obj is last
|
||||
// Swap refs_list into pending_list_addr and
|
||||
// set obj's next to what we read from pending_list_addr.
|
||||
oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr);
|
||||
// Need oop_check on pending_list_addr above;
|
||||
// see special oop-check code at the end of
|
||||
// enqueue_discovered_reflists() further below.
|
||||
if (old == NULL) {
|
||||
// obj should be made to point to itself, since
|
||||
// pending list was empty.
|
||||
java_lang_ref_Reference::set_next(obj, obj);
|
||||
} else {
|
||||
java_lang_ref_Reference::set_next(obj, old);
|
||||
}
|
||||
} else {
|
||||
java_lang_ref_Reference::set_next(obj, next_d);
|
||||
}
|
||||
java_lang_ref_Reference::set_discovered(obj, (oop) NULL);
|
||||
assert(java_lang_ref_Reference::next(obj) == NULL,
|
||||
"Reference not active; should not be discovered");
|
||||
// Self-loop next, so as to make Ref not active.
|
||||
java_lang_ref_Reference::set_next_raw(obj, obj);
|
||||
if (next_d != obj) {
|
||||
oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), next_d);
|
||||
} else {
|
||||
// This is the last object.
|
||||
// Swap refs_list into pending_list_addr and
|
||||
// set obj's discovered to what we read from pending_list_addr.
|
||||
oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr);
|
||||
// Need post-barrier on pending_list_addr. See enqueue_discovered_ref_helper() above.
|
||||
java_lang_ref_Reference::set_discovered_raw(obj, old); // old may be NULL
|
||||
oopDesc::bs()->write_ref_field(java_lang_ref_Reference::discovered_addr(obj), old);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -515,22 +475,6 @@ void DiscoveredListIterator::remove() {
|
||||
_refs_list.dec_length(1);
|
||||
}
|
||||
|
||||
// Make the Reference object active again.
|
||||
void DiscoveredListIterator::make_active() {
|
||||
// The pre barrier for G1 is probably just needed for the old
|
||||
// reference processing behavior. Should we guard this with
|
||||
// ReferenceProcessor::pending_list_uses_discovered_field() ?
|
||||
if (UseG1GC) {
|
||||
HeapWord* next_addr = java_lang_ref_Reference::next_addr(_ref);
|
||||
if (UseCompressedOops) {
|
||||
oopDesc::bs()->write_ref_field_pre((narrowOop*)next_addr, NULL);
|
||||
} else {
|
||||
oopDesc::bs()->write_ref_field_pre((oop*)next_addr, NULL);
|
||||
}
|
||||
}
|
||||
java_lang_ref_Reference::set_next_raw(_ref, NULL);
|
||||
}
|
||||
|
||||
void DiscoveredListIterator::clear_referent() {
|
||||
oop_store_raw(_referent_addr, NULL);
|
||||
}
|
||||
@ -567,8 +511,6 @@ ReferenceProcessor::process_phase1(DiscoveredList& refs_list,
|
||||
}
|
||||
// Remove Reference object from list
|
||||
iter.remove();
|
||||
// Make the Reference object active again
|
||||
iter.make_active();
|
||||
// keep the referent around
|
||||
iter.make_referent_alive();
|
||||
iter.move_to_next();
|
||||
|
@ -161,9 +161,6 @@ public:
|
||||
// Remove the current reference from the list
|
||||
void remove();
|
||||
|
||||
// Make the Reference object active again.
|
||||
void make_active();
|
||||
|
||||
// Make the referent alive.
|
||||
inline void make_referent_alive() {
|
||||
if (UseCompressedOops) {
|
||||
@ -200,9 +197,6 @@ class ReferenceProcessor : public CHeapObj<mtGC> {
|
||||
size_t total_count(DiscoveredList lists[]);
|
||||
|
||||
protected:
|
||||
// Compatibility with pre-4965777 JDK's
|
||||
static bool _pending_list_uses_discovered_field;
|
||||
|
||||
// The SoftReference master timestamp clock
|
||||
static jlong _soft_ref_timestamp_clock;
|
||||
|
||||
@ -421,13 +415,6 @@ class ReferenceProcessor : public CHeapObj<mtGC> {
|
||||
bool discovery_is_atomic() const { return _discovery_is_atomic; }
|
||||
void set_atomic_discovery(bool atomic) { _discovery_is_atomic = atomic; }
|
||||
|
||||
// whether the JDK in which we are embedded is a pre-4965777 JDK,
|
||||
// and thus whether or not it uses the discovered field to chain
|
||||
// the entries in the pending list.
|
||||
static bool pending_list_uses_discovered_field() {
|
||||
return _pending_list_uses_discovered_field;
|
||||
}
|
||||
|
||||
// whether discovery is done by multiple threads same-old-timeously
|
||||
bool discovery_is_mt() const { return _discovery_is_mt; }
|
||||
void set_mt_discovery(bool mt) { _discovery_is_mt = mt; }
|
||||
|
@ -55,30 +55,17 @@ void InstanceRefKlass::oop_oop_iterate_ref_processing_specialized(oop obj, OopCl
|
||||
}
|
||||
}
|
||||
T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
|
||||
if (ReferenceProcessor::pending_list_uses_discovered_field()) {
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
// Treat discovered as normal oop, if ref is not "active" (next non-NULL)
|
||||
if (!oopDesc::is_null(next_oop) && contains(disc_addr)) {
|
||||
// i.e. ref is not "active"
|
||||
debug_only(
|
||||
if(TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" Process discovered as normal "
|
||||
PTR_FORMAT, p2i(disc_addr));
|
||||
}
|
||||
)
|
||||
Devirtualizer<nv>::do_oop(closure, disc_addr);
|
||||
}
|
||||
} else {
|
||||
// In the case of older JDKs which do not use the discovered field for
|
||||
// the pending list, an inactive ref (next != NULL) must always have a
|
||||
// NULL discovered field.
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
// Treat discovered as normal oop, if ref is not "active" (next non-NULL)
|
||||
if (!oopDesc::is_null(next_oop) && contains(disc_addr)) {
|
||||
// i.e. ref is not "active"
|
||||
debug_only(
|
||||
T next_oop = oopDesc::load_heap_oop(next_addr);
|
||||
T disc_oop = oopDesc::load_heap_oop(disc_addr);
|
||||
assert(oopDesc::is_null(next_oop) || oopDesc::is_null(disc_oop),
|
||||
err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL"
|
||||
"discovered field", p2i(obj)));
|
||||
if(TraceReferenceGC && PrintGCDetails) {
|
||||
gclog_or_tty->print_cr(" Process discovered as normal "
|
||||
PTR_FORMAT, p2i(disc_addr));
|
||||
}
|
||||
)
|
||||
Devirtualizer<nv>::do_oop(closure, disc_addr);
|
||||
}
|
||||
// treat next as normal oop
|
||||
if (contains(next_addr)) {
|
||||
|
@ -651,11 +651,15 @@ void JDK_Version::initialize() {
|
||||
minor = micro;
|
||||
micro = 0;
|
||||
}
|
||||
// Incompatible with pre-4243978 JDK.
|
||||
if (info.pending_list_uses_discovered_field == 0) {
|
||||
vm_exit_during_initialization(
|
||||
"Incompatible JDK is not using Reference.discovered field for pending list");
|
||||
}
|
||||
_current = JDK_Version(major, minor, micro, info.update_version,
|
||||
info.special_update_version, build,
|
||||
info.thread_park_blocker == 1,
|
||||
info.post_vm_init_hook_enabled == 1,
|
||||
info.pending_list_uses_discovered_field == 1);
|
||||
info.post_vm_init_hook_enabled == 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, 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
|
||||
@ -91,7 +91,6 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
|
||||
bool _partially_initialized;
|
||||
|
||||
bool _thread_park_blocker;
|
||||
bool _pending_list_uses_discovered_field;
|
||||
bool _post_vm_init_hook_enabled;
|
||||
|
||||
bool is_valid() const {
|
||||
@ -114,18 +113,17 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
|
||||
|
||||
JDK_Version() : _major(0), _minor(0), _micro(0), _update(0),
|
||||
_special(0), _build(0), _partially_initialized(false),
|
||||
_thread_park_blocker(false), _post_vm_init_hook_enabled(false),
|
||||
_pending_list_uses_discovered_field(false) {}
|
||||
_thread_park_blocker(false), _post_vm_init_hook_enabled(false)
|
||||
{}
|
||||
|
||||
JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0,
|
||||
uint8_t update = 0, uint8_t special = 0, uint8_t build = 0,
|
||||
bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false,
|
||||
bool pending_list_uses_discovered_field = false) :
|
||||
bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false) :
|
||||
_major(major), _minor(minor), _micro(micro), _update(update),
|
||||
_special(special), _build(build), _partially_initialized(false),
|
||||
_thread_park_blocker(thread_park_blocker),
|
||||
_post_vm_init_hook_enabled(post_vm_init_hook_enabled),
|
||||
_pending_list_uses_discovered_field(pending_list_uses_discovered_field) {}
|
||||
_post_vm_init_hook_enabled(post_vm_init_hook_enabled)
|
||||
{}
|
||||
|
||||
// Returns the current running JDK version
|
||||
static JDK_Version current() { return _current; }
|
||||
@ -152,10 +150,6 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
|
||||
bool post_vm_init_hook_enabled() const {
|
||||
return _post_vm_init_hook_enabled;
|
||||
}
|
||||
// For compatibility wrt pre-4965777 JDK's
|
||||
bool pending_list_uses_discovered_field() const {
|
||||
return _pending_list_uses_discovered_field;
|
||||
}
|
||||
|
||||
// Performs a full ordering comparison using all fields (update, build, etc.)
|
||||
int compare(const JDK_Version& other) const;
|
||||
|
Loading…
Reference in New Issue
Block a user