/* * Copyright (c) 2015, 2022, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
template <typename T, class OopClosureType> bool InstanceRefKlass::try_discover(oop obj, ReferenceType type, OopClosureType* closure) {
ReferenceDiscoverer* rd = closure->ref_discoverer(); if (rd != NULL) {
oop referent = load_referent(obj, type); if (referent != NULL) { if (!referent->is_gc_marked()) { // Only try to discover if not yet marked. return rd->discover_reference(obj, type);
}
}
} returnfalse;
}
template <typename T, class OopClosureType, class Contains> void InstanceRefKlass::oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains) { // Try to discover reference and return if it succeeds. if (try_discover<T>(obj, type, closure)) { return;
}
// Treat referent and discovered as normal oops.
do_referent<T>(obj, closure, contains);
do_discovered<T>(obj, closure, contains);
}
template <typename T, class OopClosureType, class Contains> void InstanceRefKlass::oop_oop_iterate_discovered_and_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains) { // Explicitly apply closure to the discovered field.
do_discovered<T>(obj, closure, contains); // Then do normal reference processing with discovery.
oop_oop_iterate_discovery<T>(obj, type, closure, contains);
}
template <typename T, class OopClosureType, class Contains> void InstanceRefKlass::oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains) {
assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
do_referent<T>(obj, closure, contains);
do_discovered<T>(obj, closure, contains);
}
template <typename T, class OopClosureType, class Contains> void InstanceRefKlass::oop_oop_iterate_fields_except_referent(oop obj, OopClosureType* closure, Contains& contains) {
assert(closure->ref_discoverer() == NULL, "ReferenceDiscoverer should not be set");
do_discovered<T>(obj, closure, contains);
}
template <typename T, class OopClosureType, class Contains> void InstanceRefKlass::oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure, Contains& contains) { switch (closure->reference_iteration_mode()) { case OopIterateClosure::DO_DISCOVERY:
trace_reference_gc<T>("do_discovery", obj);
oop_oop_iterate_discovery<T>(obj, reference_type(), closure, contains); break; case OopIterateClosure::DO_DISCOVERED_AND_DISCOVERY:
trace_reference_gc<T>("do_discovered_and_discovery", obj);
oop_oop_iterate_discovered_and_discovery<T>(obj, reference_type(), closure, contains); break; case OopIterateClosure::DO_FIELDS:
trace_reference_gc<T>("do_fields", obj);
oop_oop_iterate_fields<T>(obj, closure, contains); break; case OopIterateClosure::DO_FIELDS_EXCEPT_REFERENT:
trace_reference_gc<T>("do_fields_except_referent", obj);
oop_oop_iterate_fields_except_referent<T>(obj, closure, contains); break; default:
ShouldNotReachHere();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.