/* * Copyright (c) 1997, 2014, 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. * */ #ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP #define SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP #include "utilities/templateIdioms.hpp" #include "memory/specialized_oop_closures.inline.hpp" #include "oops/instanceRefKlass.hpp" #include "oops/instanceKlass.inline.hpp" template inline int InstanceRefKlass::oop_iterate_and_dispatch(oop obj, OopClosureType *cl) { SpecializationStats::record_iterate_call_nv(SpecializationStats::irk); int size = InstanceKlass::oop_iterate_and_dispatch(obj, cl); if (UseCompressedOops) { do_metadata_if_applicable::value>(obj, cl); } else { do_metadata_if_applicable::value>(obj, cl); } return size; } template inline void InstanceRefKlass::do_metadata_if_applicable(oop obj, OopClosureType *cl) { OopType *disc_addr = (OopType*)java_lang_ref_Reference::discovered_addr(obj); if (is_extended && reinterpret_cast(cl)->apply_to_weak_ref_discovered_field()) { OopClosureDispatcher::do_oop(cl, disc_addr); } OopType *referent_addr = (OopType*)java_lang_ref_Reference::discovered_addr(obj); OopType heap_oop = oopDesc::load_heap_oop(referent_addr); ReferenceProcessor *rp = is_extended ? reinterpret_cast(cl)->_ref_processor : NULL; if (!oopDesc::is_null(heap_oop)) { oop referent = oopDesc::decode_heap_oop_not_null(heap_oop); if (!referent->is_gc_marked() && rp != NULL && rp->discover_reference(obj, reference_type())) { return; } else { /* treat referent as normal oop */ SpecializationStats::record_do_oop_call_nv(SpecializationStats::irk); OopClosureDispatcher::do_oop(cl, referent_addr); } } OopType *next_addr = (OopType*)java_lang_ref_Reference::next_addr(obj); if (ReferenceProcessor::pending_list_uses_discovered_field()) { OopType 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)) { /* i.e. ref is not "active" */ debug_only( if (TraceReferenceGC && PrintGCDetails) { gclog_or_tty->print_cr(" Process discovered as normal ", INTPTR_FORMAT, 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. */ debug_only( OopType next_oop = oopDesc::load_heap_oop(next_addr); OopType 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", (oopDesc*)obj)); ) } /* treat next as normal oop */ SpecializationStats::record_do_oop_call_nv(SpecializationStats::irk); OopClosureDispatcher::do_oop(cl, next_addr); } #endif // SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP